关于友元函数的问题.....
class hean{
int shangren;
int puren;
public:
friend boats::Load(int s,int p,hean &lingshi);
friend boats::Unload(hean &lingshi);
hean(int s,int p):shangren(s),puren(p){}
bool Inspect(){ return shangren>=puren?true:false;}
};
class boats
{
int shangren;
int puren;
public:
boats():shangren(0),puren(0){}
void Load(int s,int p,hean &lingshi);
void Unload(hean &lingshi);
};
void boats::Load(int s,int p,hean &lingshi)
{
shangren+=s;
puren+=p;
lingshi.shangren-=s;
lingshi.puren-=p;
}
void boats::Unload(hean &lingshi)
{
lingshi.shangren+=shangren;
lingshi.puren+=puren;
}
如上,我发现如果先定义娄hean,在编译"friend boats::Load(int s,int p,hean &lingshi);"这句时,提示boats不是一个娄名或名字空间.
换先定义娄boats时,在编译" void Load(int s,int p,hean &lingshi);"这句时,提示使用了未定义的标示符 hean
对这个问题求助....