只要子类中出现了和父类中同名的函数,父类中的所有这个名字的函数,就被屏蔽了。

静态函数成员也是如此?经过代码验证,确实如此。

#include <iostream>

using namespace std;

class A{
public:
        void print(){cout << "A::print()" << endl;}
};

class B:public A{
public:
        void print(int i ){cout << "B::print(int i)" << endl;}
};

int main()
{
        B b;
        b.print(0);
        b.A::print();

   b.print();// 这个是编译不通过的。  
return 0; }

 

posted on 2019-03-22 18:10  newbird2017  阅读(200)  评论(0编辑  收藏  举报