哪里错了,求解,运算符重载
编译通不过#include <iostream>
using namespace std;
class base
{
float real,image;
public:
base (){}
base (float x,float y):real(x),image(y){
}
base operator + (base ,base );
void show()
{
cout<<real<<" +"<<image<<"i"<<endl;
}
};
base base::operator+(base a,base b)
{
base c;
c.real=a.real+b.real;
c.image=a.image+b.image;
return c;
}
main()
{
base a(1.2,4.5),b(2.2,5.5);
base c;
c=a+b;
c.show();
}
[此贴子已经被作者于2019-8-15 19:52编辑过]