65,209
社区成员
发帖
与我相关
我的任务
分享#include<string.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;
class A1
{
public:
int operator=(int a)
{
return 8;
}
int operator+(int a)
{
return 9;
}
};
class B1 : public A1
{
public:
int operator-(int a)
{
return 7;
}
};
int main()
{
A1 x;
cout<<(x=2)<<endl;
B1 v,u;
v=u;
cout << (v + 2) << endl; // OK, print 9
cout << (v - 2) << endl; // OK, print 7
cout << (v = 2) << endl; // Error, see below
return 0;
}
代码重发了下,看得清楚