If you have class B which inherits from class A, the two values printed below might be different. Why?
B *myPointer = new B();
A *myOtherPointer = myPointer;
printf(“%x”, myPointer);
printf(“%x”, myOtherPointer);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming that
Ais a base ofBso that the assignment is valid, it might not be the only base ofB(and in particular it might not be the first base), in which case there will be an offset:Additionally, if the inheritance relationship is virtual then they will not start at the same address either: