标题:关于重载运算符的问题
取消只看楼主
ku_klox
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2010-4-3
结帖率:91.67%
已结贴  问题点数:5 回复次数:0 
关于重载运算符的问题
#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的,应该怎样改正,请个位帮帮忙!
搜索更多相关主题的帖子: 算符 载运 
2010-08-30 22:04



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-317241-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.592234 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved