C++含参数函数的继承方法
时间:12-01
来源:互联网
点击:
方法:先继承类然后映射函数。
#include
class animal
{
public:
animal(char thename);
};
animal::animal(char thename)
{
char name;
cout
class pig:public animal //先继承类,并在次写上子类映射函数
{
public:
pig(char thename);
};
pig::pig(char thename):animal(thename) //后映射函数。注意父类函数此时无需再定义数据类型
{
}
class turtle:public animal
{
public:
turtle(char thename);
};
turtle::turtle(char thename):animal(thename)
{
}
int main()
{
pig st(M);
turtle sm(n);
return 0;
}
C++含参数函数继承方 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)