问题
This question already has an answer here:
- Why aren't copy constructors “chained” like default constructors or destructors? 3 answers
- Calling the base class constructor from the derived class constructor 5 answers
Just like in the title, how do you call a base class copy constructor from a derived class copy constructor?
回答1:
You can specify base initialization in the initialization list:
Derived:: Derived( const Derived& other ): Base( other )
{ /* ... */ }
回答2:
Derived( Derived const& d )
: Base(d)
/* some member initialization */
{
/* ... */
}
Am I missing something?
来源:https://stackoverflow.com/questions/17311382/how-to-call-base-class-copy-constructor-from-a-derived-class-copy-constructor