C++ 如何从派生类复制构造函数调用基类复制构造函数?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17311382/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 21:05:06 来源:igfitidea点击:
How to call base class copy constructor from a derived class copy constructor?
提问by slow
Just like in the title, how do you call a base class copy constructor from a derived class copy constructor?
就像标题一样,如何从派生类复制构造函数调用基类复制构造函数?
回答by perreal
You can specify base initialization in the initialization list:
您可以在初始化列表中指定基本初始化:
Derived:: Derived( const Derived& other ): Base( other )
{ /* ... */ }
回答by zindorsky
Derived( Derived const& d )
: Base(d)
/* some member initialization */
{
/* ... */
}
Am I missing something?
我错过了什么吗?

