This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
A question about complier for C++
- From: Fan Lu <carboy dot lu at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 25 Jun 2008 21:51:13 +0800
- Subject: 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!