我试图理解这一行为,但似乎我没有。 请参看该法典:
#include <iostream>
using namespace std;
class Base
{
public:
void operator=(const Base& rf)
{
cout << "base operator=" << endl;
this->y = rf.y;
}
int y;
Base() : y(100) { }
};
class Derived : public Base
{
public:
int x;
Derived() : x(100) { }
};
int main()
{
Derived test;
Derived test2;
test2.x = 0;
test2.y = 0;
test.operator=(test2); // operator auto-generated for derived class but...
cout << test.x << endl << test.y << endl;
cin.ignore();
return 0;
}
PROGRAM OUTPUT:
> base operator=
> 0
> 0
Now where I m confused is:
The rule says that a derived class never inherits the assigment operator, instead it creates its own operator=
however in this example base s operator=
gets invoked on the derived class.
第二,我能够明确地以衍生产品类别援引变迁经营人,而这反过来又在衍生产品类别中作了明确规定。
现在,如果我正确理解,这意味着任何用户界定的基地运营商总是在衍生类别上援引?