C ++继承隐藏方法?

时间:2014-10-07 17:18:46

标签: c++ inheritance

为什么我们不能调用这个函数Base :: P(int)?

class Base
{   
protected:
    string s = "Base";
public:
    void P(int a){ cout << "Base" << endl; }
};
class Derived : public Base

public:
    using Base::s;  
    void P(){ cout << "Derived" << endl; }
};

int main()
{
    Derived a;
    a.P(2);   // Error, Why we can not use Base::P(int)?
}

为什么我们不能使用Base :: P(int)?

0 个答案:

没有答案
相关问题