1 回答

TA贡献1779条经验 获得超6个赞
我也不会,有点太难了;
#include <iostream>
using namespace std;
class beijing;
class shanghai
{
public:
shanghai(int a,int b,int c)
{
benchi=a;
baoma=b;
aodi=c;
total=benchi+baoma+aodi;
}
int get_total()
{
return total;
}
friend int count (beijing b,shanghai s);
private:
int aodi,benchi,baoma,total;
};
class beijing
{
public:
beijing(int a,int b,int c)
{
benchi=a;
baoma=b;
aodi=c;
total=benchi+baoma+aodi;
}
int get_total()
{
return total;
}
friend int count(beijing b,shanghai s);
private:
int aodi,benchi,baoma,total;
};
int count(beijing b,shanghai s)
{
return b.total+s.total;
}
int main()
{
int a,b,c,d,e,f;
cout<<"上海的车奔驰(a)宝马(b)奥迪(c)"<<endl;
cin>>a>>b>>c;
cout<<"北京的车奔驰(d)宝马(e)奥迪(f)"<<endl;
cin>>d>>e>>f;
shanghai s(a,b,c);
beijing b(d,e,f);
cout<<"the total count of shanghai is: "<<s.get_total()<<endl;
cout<<"the total count of beijing is: "<<b.get_total()<<endl;
cout<<"the total count of shanghai and beijing is: "<<count(b,s)<<endl;
}
我这也错了
- 1 回答
- 0 关注
- 117 浏览
添加回答
举报