For example, if i have a class like this;
#import "B.h"
class A
{
B object;
};
would B's constructor get called when I created a A object?
For example, if i have a class like this;
#import "B.h"
class A
{
B object;
};
would B's constructor get called when I created a A object?
Yes, the default constructor will be called (if present) or a compiler error will be triggered if there is no default constructor for B
.
Yes. One way to test this is to put some simple cout calls in the constructors to watch the constructor calls happen.
Yes, member constructor is called in order of declaration for the containing class.
One should mention that this rule apply both ways, calling class 'A's destructor calls its members default destructor's.