24

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

keelar
  • 5,814
  • 7
  • 40
  • 79
slow
  • 805
  • 3
  • 13
  • 27

2 Answers2

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