When class A
contains an instance of class B
, constructing an instance of A
also requires construction of the contained instance of B
.
If no constructor of B
is listed in the initialiser of class A
, the default is to invoke a constructor of B
that accepts no arguments. For example
class A
{
public:
A::A() {};
private:
B b;
};
is functionally equivalent to
class A
{
public:
A::A() : b() {};
private:
B b;
};
This involves a constructor of B
with no arguments. If no such constructor exists, the result is a diagnostic (error message). Since you have declared/defined a constructor with arguments, a constructor for B
with no arguments is not implicitly generated.