22

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

4

2 回答 2

41

您可以在初始化列表中指定基本初始化:

Derived:: Derived( const Derived& other ): Base( other )
{ /* ... */ }
于 2013-06-26T04:15:30.227 回答
10
Derived( Derived const& d )
: Base(d)
/* some member initialization */
{
  /* ... */
}

我错过了什么吗?

于 2013-06-26T04:19:44.037 回答