如何从派生类复制构造函数调用基类复制构造函数? [英] How to call base class copy constructor from a derived class copy constructor?
本文介绍了如何从派生类复制构造函数调用基类复制构造函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
就像在标题中,你如何从派生类复制构造函数调用基类复制构造函数?
解决方案
您可以在初始化列表中指定基本初始化:
Derived :: Derived(const Derived& other):Base(other)
pre>
{/ * ... * /}
Just like in the title, how do you call a base class copy constructor from a derived class copy constructor?
解决方案You can specify base initialization in the initialization list:
Derived:: Derived( const Derived& other ): Base( other ) { /* ... */ }
这篇关于如何从派生类复制构造函数调用基类复制构造函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文