Just like in the title, how do you call a base class copy constructor from a derived class copy constructor?
Asked
Active
Viewed 4.1k times
24
-
3The more important Q is why do you want to do this? – Alok Save Jun 26 '13 at 04:11
-
@AlokSave obviously, to get their code to compile and come out with their app, they need to do this. Duh – MathCrackExchange Aug 29 '22 at 03:18
2 Answers
43
You can specify base initialization in the initialization list:
Derived:: Derived( const Derived& other ): Base( other )
{ /* ... */ }

perreal
- 94,503
- 21
- 155
- 181
11
Derived( Derived const& d )
: Base(d)
/* some member initialization */
{
/* ... */
}
Am I missing something?

zindorsky
- 1,592
- 9
- 9