views:

64

answers:

1

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()’
+9  A: 

In B's constructor, you would do something like this:

B::B() : a(0, 0)
{
    // ctor here
}
Starkey
That did it! Thanks!
wrongusername