【发布时间】:2013-06-23 01:54:16
【问题描述】:
就像标题一样,如何从派生类复制构造函数调用基类复制构造函数?
【问题讨论】:
-
更重要的问题是你为什么要这样做?
标签: c++ inheritance constructor copy-constructor
就像标题一样,如何从派生类复制构造函数调用基类复制构造函数?
【问题讨论】:
标签: c++ inheritance constructor copy-constructor
您可以在初始化列表中指定基础初始化:
Derived:: Derived( const Derived& other ): Base( other )
{ /* ... */ }
【讨论】:
Derived( Derived const& d )
: Base(d)
/* some member initialization */
{
/* ... */
}
我错过了什么吗?
【讨论】: