Reputation: 4275
If I have a class A
without default constructor and a class B
class B {
private:
A m_a;
public:
B(A a) : m_a(a) {}
};
How is m_a now initialized? By the assignment operator of A or by the copy constructor?
Upvotes: 0
Views: 298
Reputation: 254431
By the copy constructor, since it's being copy-initialised.
The assignment operator is used for assignment to an existing object, never for initialisation of a new object.
Upvotes: 3