请教c++高手,帮忙看看哪错了,感谢了啊。
#include<iostream>usingnamespacestd;classCar;classBoat{public:voidgetWeight1(){cout<<...
#include<iostream>
using namespace std;
class Car;
class Boat
{
public:
void getWeight1()
{
cout<<"input the Boat's Weight:";
cin>>weight1;
}
int getWeightToal(Car &w);
private:
int weight1;
};
class Car
{
public:
void getWeight1()
{
cout<<"input the Boat's Weight:";
cin>>weight2;
}
friend int getWeightToal(Boat &w)
{
int toalw;
toalw=weight2+w.weight1;
cout<<toalw;
}
private:
int weight2;
};
int main()
{
void getWeight1();
void getWeight2();
cout<<"the toalweight is:";
int getWeightToal();
return 0;
} 展开
using namespace std;
class Car;
class Boat
{
public:
void getWeight1()
{
cout<<"input the Boat's Weight:";
cin>>weight1;
}
int getWeightToal(Car &w);
private:
int weight1;
};
class Car
{
public:
void getWeight1()
{
cout<<"input the Boat's Weight:";
cin>>weight2;
}
friend int getWeightToal(Boat &w)
{
int toalw;
toalw=weight2+w.weight1;
cout<<toalw;
}
private:
int weight2;
};
int main()
{
void getWeight1();
void getWeight2();
cout<<"the toalweight is:";
int getWeightToal();
return 0;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询