#include<iostream>
using namespace std;
class Complex
{
public:
Complex(double r,double i):real(r),imag(i){}
Complex operator +(Complex &s);
void display();
private:
double real;
double imag;
};
Complex Complex:: operator +(Complex &s)
{
return(Complex(real+s.real,imag+s.imag));
}
void Complex::display()
{
cout<<real<<"+"<<imag<<"i"<<endl;
}
int main()
{
Complex c1(4.0,2.0),c2(1.0,1.0);
Complex c3=c1+c2;
c3.display();
}1.
最新推荐文章于 2024-03-12 14:10:56 发布
1万+

被折叠的 条评论
为什么被折叠?



