编程语言
首页 > 编程语言> > C++中简单的继承关系

C++中简单的继承关系

作者:互联网

#include<iostream>
using namespace std;
class Tm{
public:
int show01();
void show(){
cout<<"my name is xietingming!"<<endl;
}
Tmd(int a,int b,int c){
this->a=a;
this->b=b;
this->c=c;
}
protected:
int a;
int b;
int c;
};
int Tm::show01(){
return a+b+c;
}
class B:public Tm{
public :
int max(){
return a*c*b;
}
int show00();
};
int B::show00(){
return a*c;
}
int main(){


Tm tm;
tm.Tmd(1,2,3);
B b;
b.Tmd(1,2,2);
cout<<b.show01()<<endl;
cout<<endl;
cout<<b.show00()<<endl;
cout<<b.max()<<endl;
cout<<tm.show01();

}

标签:return,cout,继承,C++,int,Tm,Tmd,简单,public
来源: https://www.cnblogs.com/hongyixiaojiang/p/15902806.html