A question about complier for C++

Fan Lu carboy.lu@gmail.com
Wed Jun 25 13:52:00 GMT 2008


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!




More information about the Gcc-help mailing list