Just like in the title, how do you call a base class copy constructor from a derived class copy constructor?
Asked
Active
Viewed 3.8k times
22
-
3The more important Q is why do you want to do this? – Alok Save Jun 26 '13 at 04:11
2 Answers
41
You can specify base initialization in the initialization list:
Derived:: Derived( const Derived& other ): Base( other )
{ /* ... */ }
perreal
- 90,214
- 20
- 145
- 172
10
Derived( Derived const& d )
: Base(d)
/* some member initialization */
{
/* ... */
}
Am I missing something?
zindorsky
- 1,572
- 9
- 9