Is this constructor correct?

c++

Solution

This is correct. However, since `b` is of class type, the default constructor will be called automatically if `b` isn't mentioned in `A::A`'s initialization list, so you don't need to mention it at all.

Problem

I have two classes A and B, and in class A I have an member of type B: ``` class B { public: B(); //default constructor }; class A { public: A(); //constructor B b; }; ``` This is the definition of class A's constructor: ``` A::A() : b() {} ``` Here, I tried to initialize `b` using the initialization list. My question is, is this way to initialize `b` correct, or am I just creating another temporary object named `b` inside the constructor of A that has nothing to do with `A::b`?

Original source