22

Just like in the title, how do you call a base class copy constructor from a derived class copy constructor?

keelar
  • 5,574
  • 6
  • 37
  • 75
slow
  • 753
  • 3
  • 11
  • 25

2 Answers2

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