#include
using namespace std;
class person
{
friend void operator-(person);
private:
int iapple;
public:
person(int iapple);
void operator-();
void display();
};
int main()
{
int m;
person xiaowang(5);
cout<<"\n调用operator-()负号运算符函数前"< xiaowang.display();
operator-(xiaowang);
cout<<"\n调用operator-()负号运算符函数后"< xiaowang.display();
cin>>m;
return 0;
}
person::person(int iapple)
{
this->iapple=iapple;
}
void operator-(person p1)
{
p1.iapple=-p1.iapple;
}
void person::display()
{
cout<<"iapple="<}
这个编译时出现的错误是这样的:
atal 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 时出错.
程序10.6负号运算符全局函数重载.exe - 1 error(s), 0 warning(s)
请大家帮我看看这是怎么回事,帮我解释一下,(这是我照这书上的程序的例子写的,只是想测试一下),看看怎样修改一下,小弟我在这先谢过
--------------------next---------------------
阅读(1504) | 评论(0) | 转发(0) |