Objects as a data member of another class
Posted on 2003-12-08
In my design, I have a class A which contains an object of type B. Eg:
In class A, by declaring an object of B eg:
does this mean that I already have an object of type B created in the stack?
Can I then do this:
someAObject.myBObject.val = 5;
without having to create the B object?
In a method in class A can I just refer to the B object even though I haven't yet created an A object?
For example, in A's method hello() can I do this?
myBObject.val = 10;
even though nowhere have I actually created an A object or a B object except for the declaration of B in the class A?