主题:关于运算符重载的程序问题!高人请帮解决一下
#include<iostream.h>
class Counter
{
public:
Counter(double a){x1=a;}
Counter operator+(Counter C2);
void display();
private:
double x1;
};
Counter Counter::operator+(Counter C2)
{
return Counter (x1+C2.x1);
}
void Counter::display()
{
cout<<x1;
}
int main()
{
Counter C1(2.0),C2(9.0),C;
cout<<"C1=";C1.dispaly();
cout<<"C2=";C2.display();
C=C1+C2;
cout<<"C=C1+C2= ";C.display();
return 0;
}
运行错误说:
G:\c++作业\作业3_3\1.cpp(26) : error C2512: 'Counter' : no appropriate default constructor available
G:\c++作业\作业3_3\1.cpp(27) : error C2039: 'dispaly' : is not a member of 'Counter'
G:\c++作业\作业3_3\1.cpp(4) : see declaration of 'Counter'