标题:关于加号重载
取消只看楼主
freshman42
Rank: 1
等 级:新手上路
威 望:1
帖 子:94
专家分:0
注 册:2005-12-4
 问题点数:0 回复次数:2 
关于加号重载

#include<iostream>
using namespace std;
class Myclass
{
int num;
public:
Myclass(int a){num=a;};
friend Myclass &operator +(const int a,const Myclass t);
};
Myclass & Myclass::operator +(const int a,const Myclass t)
{
this->num=a+t.num;
return *this;
}

错误提示是:
Compiling...
grre.cpp
E:\C++\c++\fgh\grre.cpp(8) : 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
Error executing cl.exe.

grre.obj - 1 error(s), 0 warning(s)
这是什么错误

搜索更多相关主题的帖子: 加号 重载 
2006-05-04 23:26
freshman42
Rank: 1
等 级:新手上路
威 望:1
帖 子:94
专家分:0
注 册:2005-12-4
得分:0 

我要的是类的每一个数据成员加上一个整数!不是两个类的相加!
你的程序我刚才运行了一下 还是有错误:
Compiling...
fjytjyt.cpp
e:\c++\c++\egdstgrer\fjytjyt.cpp(9) : 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
Error executing cl.exe.

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


2006-05-05 00:06
freshman42
Rank: 1
等 级:新手上路
威 望:1
帖 子:94
专家分:0
注 册:2005-12-4
得分:0 

我也觉得我的vc6.0有问题.好象一用到友元就有哪个错.
不知道有没有哪个高手指点一下.


2006-05-05 01:20



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




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

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