#includeclass Fuel;class Engine{int a,b;public:Engine(int xa=1,int xb=2){a=xa;b=xb;};friend class Fuel;int &geta(){return a;}int &getb(){return b;}};class Fuel{Engine e;public:void show();};void Fuel::show(){cout

问题描述:

#include
class Fuel;
class Engine
{
int a,b;
public:
Engine(int xa=1,int xb=2){a=xa;b=xb;};
friend class Fuel;
int &geta(){return a;}
int &getb(){return b;}
};
class Fuel
{
Engine e;
public:
void show();
};
void Fuel::show()
{cout

楼主,把Fuel f(); 改为 Fuel f;就OK了 Fuel f; 调用无参构造函数,当无参构造函数没写时,系统自动默认.// Fuel(){} //无参构造函数// Fuel(Engine en){e=en;} //有参构造函数 当你写有参构造函数时,必要写无参构造函...