Jaspreet wrote:
Yong W wrote: Sorry, I have a mistake. the class A and B's definition is:
class B
{
int b;
};
class A
{
B obj;
};
Thanks for posting the correct code. You are giving the full scope for
member 'b' when accessing it.
Assuming you have the pubic access specifier. If you need to give full
scope for member B you would give - A::B.
Now if you need to access 'b' you would further use the scope
resolution to get :
A::B::b
(pay special care to upper and lower case Bs)
This again makes no sense. 'B' is not declared in 'A's scope, so you
cannot write 'A::B'. You can write 'A::obj', possibly. You can write
B A::*. From the latter you can try writing
int A::*B::*p;
which declares a pointer to an int member of 'B' that is a member of 'A'.
Problem is, I have no idea how to initialise it. I don't see any syntax
for that.
V
--
Please remove capital As from my address when replying by mail