关于重载运算符的问题
#include "stdafx.h" //这里提示出错了#include <iostream>
using namespace std;
class real
{
public:
real(double value=0);
real operator -()const;
real operator ++();
private:
double value;
};
real::real(double value)
{
this->value=value;
}
real real::operator -()const
{
return real(-value);
}
real real::operator ++()
{
value++;
return real(value);
}
void main()
{
real r1(12.3);
cout<<r1<<endl;
cout<<++r1<<endl;
cout<<r1<<endl;
cout<<-r1<<endl;
}
我是用vc6.0的,应该怎样改正,请个位帮帮忙!