课程
/后端开发
/C++
/C++远征之继承篇
:后面如何写:ChildLabourer(string name, int age):
2015-11-01
源自:C++远征之继承篇 6-4
正在回答
两个基类加传参 :Worker(name), Children(age)
初始化列表:
ChildLabourer(string name, int age):Worker(name),Children(age)
class ChildLabourer:public Worker,public Children
{
public:
cout << "ChildLabourer" << endl;
}
~ChildLabourer()
cout << "~ChildLabourer" << endl;
};
ChildLabourer(string name="Jack", int age=21):Worker(name),Children(age)
举报
继承,C++面向对象三大特征之一,通过编码实践方式讲解到操作层面