C++友元函数问题
请各位大侠帮忙看一下这个程序的友元使用错在哪:#include<iostream>
using namespace std;
class Gbank{
private:
double balance;
public:
double acount(double k)
{
balance=k;
}
friend void total(Cbank a,Bbank b,Gbank c);
};
class Bbank{
private:
double balance;
public:
double acount(double j)
{
balance=j;
}
friend void total(Cbank a,Bbank b,Gbank c);
};
class Cbank{
private:
double balance;
public:
double acount(double i)
{
balance=i;
}
friend void total(Cbank a,Bbank b,Gbank c);
};
double m=0;
void total(Cbank a,Bbank b,Gbank c)
{
m=a.balance+b.balance+c.balance;
cout<<"总存款为:"<<m<<endl;
}
void main()
{
Cbank a;
Bbank b;
Gbank c;
double i,j,k;
cout<<"请分别输入三个银行的存款:";
while(1)
{
cin>>i>>j>>k;
a.acount(i);
b.acount(j);
c.acount(k);
total(Cbank a,Bbank b,Gbank c);
}
}