#include<iostream>
#include<cstring>
using namespace std;
class Complex
{
public :
Complex(){imag=0;real=0;}
Complex(double a,double b){real=a;imag=b;}
operator double(){return real;}
void setting();
private:
double real;
double imag;
};
void Complex::setting()
{
cin>>real>>imag;
}
int main()
{
double c,e,a,b;
Complex t1(a,b)//t1后面需要加上括号;
t1.setting();
cin>>c;
e=c+t1;
cout<<e;
return 0;
}
1274面向对象程序设计上机练习十二(运算符重载)

最新推荐文章于 2020-11-26 22:48:20 发布