I have a very interesting observation that may or may not be expected. I have two very complicated classes that each extend many other unrelated classes. For reference, one is a socket and one is a virtual device. During construction of the virtual device, I want to pass the address of the device to the a socket object. The socket object is also part of the virtual device. It basically looks like this
class TcpSocket : public Socket, public OtherThing {
void Init(OtherOtherClass *device){
printf("0x%x\n", device); //0x1aaaf794
}
};
ā
class Device : public OtherClass, public OtherOtherClass {
Device(){
printf("0x%x\n", this); //0x1aaaf6d0
this->socket.Init(this);
printf("0x%x\n", this); //0x1aaaf6d0
}
TcpSocket socket;
};
I cannot reproduce this in a sandbox environment, but when I print out the addresses, they are different. So maybe I will just ask the question.
In function TcpSocket::Init it is expecting an OtherOtherClass* and not a Device*. Is this the reason why the address appears to be different?