|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<iostream>
using namespace std;
class drive
{
private:
int wheel;
double weight;
public:
drive(int a,double b):wheel(a),weight(b)
{
cin>>a>>b;
wheel=a;weight=b;
}
};
class car:private drive
{
private:
double weights;
public:
car(int a,double b,double c)
{
drive(a,b);
cin>>c;
weights=c;
}
void print();
};
class truck:private drive
{
private:
double weighting;
public:
truck(int a,double b,double d)
{
cin>>a>>b;
drive(a,b);
cin>>d;
weighting=d;
}
void print1();
};
int main()
{
car s1(0.0);
truck s2(0,0.0,0.0);
s1.print();
s2.print1();
return 0;
}
void car::print()
{
cout<<"数据为:"<<endl;
cout<<drive(wheel,weight))<<endl;
cout<<weights;
}
void truck::print1()
{
cout<<"数据为:"<<endl;
cout<<drive(wheel,weight)<<endl;
cout<<weighting;
}
这个程序哪里有错啊!!! |
|