If I have a class A with only a copy constructor and a constructor with  parameters int and int, and I place that class inside a class B:
class B
{
public:
    B();
private
    A a;
}
How would I initialize a inside B's constructor?
I've tried a(0, 0), a = A(0, 0), but not surprisingly neither worked, and I receive a
error: no matching function for call to ‘A::A()’
                In B's constructor, you would do something like this:
B::B() : a(0, 0)
{
    // ctor here
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With