运算符重叠 [英] operator overloding
问题描述
#include< iostream>
使用名称空间std;
类INTEGER
{
公开:
int * ref;
int num_1;
int num_2;
int num_3;
INTEGER运算符+(INTEGER sref)
{
如果(num_1 == num_2)
{
=((* this).ref + sref.ref);
}
否则,如果(num_1!= num_2)
{
cout<<更改值"<< endl;
}
}
};
void main()
{
整数num_1(1);
整数num_2(1);
整数num_3;
num_3 = num_1 + num_2;
cout<< num_3.ref;
cin.get();
}
请zzzz帮我解决它的错误..:(
#include<iostream>
using namespace std;
class INTEGER
{
public:
int *ref;
int num_1;
int num_2;
int num_3;
INTEGER operator+(INTEGER sref)
{
if (num_1==num_2)
{
=((*this).ref + sref.ref);
}
else if (num_1 != num_2)
{
cout<<"change the value"<<endl;
}
}
};
void main()
{
INTEGER num_1(1);
INTEGER num_2(1);
INTEGER num_3;
num_3=num_1+num_2;
cout<<num_3.ref;
cin.get();
}
plzz help me out with its errors..:(
推荐答案
Hello,
谢谢您的发帖!  ;我建议将您的问题发布到MS论坛之一中,
这篇关于运算符重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!