This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

A question about complier for C++


I want to know :

Do the copy assignment operator and copy constructor in derived class
will automatically invoke the corresponding functions in base class?

that to say:

class A have a copy constructor and a copy assignment funciton.
And class B is derived from class A, and also define a copy constructor
and a copy assignment funciton.

class A
{
//...
public:
A:A(const A& rhs);
A& operator=(const A& obj);
};

class B:public A
{
public:
B:B(const B& rhs);
B& operator=(const B& obj);
};

When I call the B:B or B& operator= function, will the compiler invoke
the A:A or A& operator= function automatically?

Or I need explicit invoke the A:A or A& operator= in B:B or B& operator=?



Thanks!



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]