C
Christian Christmann
Hi,
I've a class that contains a private member object
that in turn is a reference:
class A
{
public:
A( classB & );
private:
classB &mB;
};
A::A( classB &B )
: mB( B )
{
}
What happens in the constructor?
Will the copy constructor of classB be invoked?
Or will just the reference of B be assigned to
mB without calling any constructors?
Is it reasonable to add a copy constructor and
an assignment operator for class A? Or will this
be handled by the default constructors and operators?
Regards,
Chris
I've a class that contains a private member object
that in turn is a reference:
class A
{
public:
A( classB & );
private:
classB &mB;
};
A::A( classB &B )
: mB( B )
{
}
What happens in the constructor?
Will the copy constructor of classB be invoked?
Or will just the reference of B be assigned to
mB without calling any constructors?
Is it reasonable to add a copy constructor and
an assignment operator for class A? Or will this
be handled by the default constructors and operators?
Regards,
Chris