如下, 在子类 engineer 的构造函数后面跟冒号调用了父类 employee 的构造函数。
(C++ Programming Made Simple 2ndE, Chapter 9, Page 231)
class employee
{
public:
employee(int id, char *name);
};
class engineer : public employee
{
public:
engineer(int id, char *name, char *department);
}
engineer::engineer(int id, char *name, char *department) : employee(id, name)
{
//....
}
|
阅读(1304) | 评论(0) | 转发(0) |