欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

專注電子技術學習與研究
當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

C++含參數函數的繼承方法

作者:黃波海   來源:本站原創   點擊數:  更新時間:2014年03月06日   【字體:

方法:先繼承類然后映射函數。
#include <iostream.h>

class animal
{
public:
animal(char thename);

};

animal::animal(char thename)
{
char name;
cout<<thename<<endl;
}

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;
}

 

關閉窗口

相關文章