0
以下代碼將退出執行過程。oop操作符重載未返回正確的值
有些想法?
我在想,t1不等於t2,所以我試圖按字節t1和t2複製字節。但那並沒有奏效。
#include<stdio.h>
class test{
int x;
public:
test(){ x=1; }
bool operator==(test &temp);
};
bool test::operator==(test &temp){
if(*this==temp){
printf("1");
return true;
}
else{
printf("2");
return false;
}
}
void main(){
test t1, t2;
t1==t2;
}