#include<iostream>
using namespace std;
class Container{
public:
Container(double r=0,double i=0);
friend Container operator+(const Container c1,const Container c2);
void print() ;
private:
double real,imag;
};
Container::Container(double r,double i)
{ real=r;
imag=i;
}
Container operator+(const Container c1,const Container c2)
{ Container temp;
temp.real=c1.real+c2.real;
temp.imag=c1.imag+c2.imag;
return temp;
}
void Container::print()
{ cout<<" ("<<real<<", "<<imag<<") "<<endl;
}
int main()
{ Container c1(2.4,3.6),c2(4.1,6.3);
Container c;
c=c1+c2;
c.print();
return 0;
}
7.12
最新推荐文章于 2024-07-12 19:00:17 发布