找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 1251|回复: 3

运算符重载问题

[复制链接]
发表于 2009-11-4 00:27:06 | 显示全部楼层 |阅读模式 IP:江苏扬州
下面程序在vc6.0里面运行报错!请指教!报错在后面有提示!
**********************************
#include <iostream>
using namespace std;
class Test
{
public:
Test(int a = 0)
{
Test::a = a;
}
friend Test operator +(Test,Test);
friend Test operator ++(Test);
public:
int a;
};
Test operator +(Test temp1,Test temp2)//+运算符重载函数
{
//cout<<temp1.a<<"|"<<temp2.a<<endl;//在这里可以观察传递过来的引用对象的成员分量
Test result(temp1.a+temp2.a);
return result;
}
Test operator ++(Test temp)//++运算符重载函数
{
temp.a++;
return temp;
}
int main()
{
Test a(100);
Test c=a+a;
cout<<c.a<<endl;
c++;
cout<<c.a<<endl;

}
***********************************************
--------------------Configuration: ddd - Win32 Debug--------------------
Compiling...
Text2.cpp
D:\source\ddd\Text2.cpp(10) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
执行 cl.exe 时出错.
Text2.obj - 1 error(s), 0 warning(s)
发表于 2009-11-4 00:27:07 | 显示全部楼层 IP:江苏扬州
#include <iostream>
using namespace std;
改为
#include <iostream.h>试试
回复

使用道具 举报

发表于 2009-11-4 00:27:08 | 显示全部楼层 IP:江苏扬州
有时编译器就是这样的.你不防在友元涵数的返回值加上一个&,我想它的返回值是用的引用.
friend Test& operator +(Test,Test);
friend Test& operator ++(Test);
回复

使用道具 举报

发表于 2009-11-4 00:27:09 | 显示全部楼层 IP:江苏扬州
这粘贴板出问题了,粘贴不上去,你去这里看
http://post.baidu.com/f?kz=139489333
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 21:29 , Processed in 0.276780 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表