久久ER99热精品一区二区-久久精品99国产精品日本-久久精品免费一区二区三区-久久综合九色综合欧美狠狠

新聞中心

EEPW首頁 > 嵌入式系統 > 設計應用 > C++含參數函數的繼承方法

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

作者: 時間:2016-12-01 來源:網絡 收藏
方法:先繼承類然后映射函數。

#include

本文引用地址:http://cqxgywz.com/article/201612/324433.htm

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



評論


技術專區

關閉