operator =的C ++继承

时间:2016-07-12 12:15:41

标签: c++ inheritance

请参阅此代码片段:

class Base {
public:
    const Base& foo      (const int&);
    const Base& operator=(const int&);
};

class Derived : public Base {};

void fn() {
    Derived   c;

    c.foo(3);  // compiles fine (as expected)
    c = 3;     // error: no match for ‘operator=’
}

问题是为什么operator=没有像Base那样从Derived继承到foo()

标准中是否有某些内容使operator=在继承方面特别?

由于

0 个答案:

没有答案