Link to home
Start Free TrialLog in
Avatar of luoys
luoys

asked on

Inheritance

Class A
{
int x;
}

Class B
{
int y;
}

Class C : public A, B
{
int z;
}

A *aa;
B *bb;
C cc;

aa = &c;
bb = &c;

Please can you tell  me  - do aa and bb point to the same address? If yes or no....why?
Avatar of List244
List244

Luoys, that code will not run for many reasons.  
First:
class is ALWAYS lowercase.
Second:
Each class ends with a ;
Third:
You can not set a variable (aa) equal to a class (c)

With all that said, they should not point to the same address.  aa should point to C.x
bb should point to C.y  Because class A only has one member as to Class B, and they
are different members than eachother, so the address should be different.
SOLUTION
Avatar of List244
List244

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ah, that is true, I just put C.x and C.y .. because that is all that is there.. lol