//3、定义一个复数类,定义友元函数,实现两个复数可以判别是否相等(==),并给出主函数应用该类。
#include"iostream"
using namespace std;
class complex1
{
private:
int real,iamg;
public:
complex1(int x,int y):real(x),iamg(y){}
friend void judge(complex1 c,complex1 cc);
};
void judge(complex1 c,complex1 cc)
{
if(cc.real==c.real&&cc.iamg==c.iamg)
cout<<"两个复数相等"<<endl;
else
cout<<"两个复数不相等"<<endl;
}
int main()
{
complex1 c1(2,3),c2(2,3);
judge(c1,c2);
return 0;
}