[LC++]Copy constructor etc

Mark Phillips mark at austrics.com.au
Tue Jul 24 18:03:46 UTC 2001


Suppose I have a class defined as follows:

class myClass {
  public:
    vector<int> myVec;
}

and suppose C1 and C2 are to instances
of myClass and somewhere down the
track I write the code:

C1=C2;

I have a few questions.

1. Is the copy constructor called, or is
operator= called?  (Well obviously
there is no "operator=" defined for
this class, but what if there were?)

2. Assuming it is the copy constructor
which is called, myClass will use the
default copy constructor.  Will the
default one behave appropriately in this
case?  Ie does it do a straight bit copy,
or will it use the vector copy constructor?


Thanks,

Mark.





More information about the tuxCPProgramming mailing list