标题:[求助]c++ji基础问题
取消只看楼主
cl_zdl
Rank: 1
等 级:新手上路
威 望:1
帖 子:71
专家分:0
注 册:2006-10-11
 问题点数:0 回复次数:1 
[求助]c++ji基础问题

这是我写的重载运算符的小程序但是有错误,希望大家帮忙看一下。谢谢!
#include<iostream>
using namespace std;
class Point {
private:int m;
public: Point(int a){m=a;}
Point operator ++(int){ Point point=*this;
++( *this);
return point;}
Point operator --(int){Point point=*this;
--(*this);
return point;}
};
void main(){
int m;
cout<<"please enter your numbaer:"<<endl;
cin>>m;
Point point(m);
cout<<"point++"<<point++<<endl<<"point--:"<<point--<<endl;
}
错误调试:
--------------------Configuration: 11 - Win32 Debug--------------------
Compiling...
11.cpp
D:\学习文件\CL\8-10\11\11.cpp(7) : error C2675: unary '++' : 'class Point' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\学习文件\CL\8-10\11\11.cpp(10) : error C2675: unary '--' : 'class Point' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\学习文件\CL\8-10\11\11.cpp(18) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class Point' (or there is no acceptable conversion)
执行 cl.exe 时出错.

11.obj - 1 error(s), 0 warning(s)

搜索更多相关主题的帖子: Point point 基础 operator 
2006-10-24 08:25
cl_zdl
Rank: 1
等 级:新手上路
威 望:1
帖 子:71
专家分:0
注 册:2006-10-11
得分:0 

能写详细点吗 ?我对运算符重载不太会,希望你能帮我一下!谢谢版主啦!麻烦你了!

2006-10-24 19:50



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




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

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