c++中简单的继承

#include<iostream>
using namespace std;
class Time {
public :
show(double a, double b, double c) {
this->a = a;
this->b = b;
this->c = c;
}
double show01();
protected:
double a;
double b;
double c;
};
double Time::show01() {
return a + b * c;
}
class A: public Time {
public :
double show11();
};
double A::show11() {
return a * b * c;

}
int main() {
// double a;
// double b;
// double c;
// cin>>a>>b>>c;
// Time t;
// A a;
// a.show(a,b,c);
// cout<<a.show11();
// cout<<endl;
// t.show(a,b,c);
// cout<<t.show01()<<endl;
// return 0;
double a;
double b;
double c;
cin>>a>>b>>c;
Time s;
A m;
m.show(a, b, c);
s.show(a, b, c);
cout << s.show01() << endl;
cout << m.show01() << endl;
cout << m.show11() << endl;
}

 

上一篇:1116 Come on Let‘s C (20 分) (模拟 质数


下一篇:数据结构(C语言版)-- 图笔记