下列程序中声明了两个类AA和BB,其中函数“print”是类AA的成员函数,但是类BB的友元函数。 请在①、②和
下列程序中声明了两个类AA和BB,其中函数“print”是类AA的成员函数,但是类BB的友元函数。
请在①、②和⑧处各填入正确的内容,使程序能正常运行。
include<iostream.h>
【 】;
class AA{
int t;
public:
AA(int x){t=x;}
void print(BB &b) ;
};
class BB{
int s;
public:
BB(int y){s=y;}
friend void 【 】 print(BB &);
};
void 【 】
{ cout<<"AA:"<<t<<"BB: "<<w.s<<end1;}<
void main(){
AA m(6);
BB n(8);
m.print(n);
}
输出结果为:AA:6;BB:8