首页 > 代码库 > private virtual in c++

private virtual in c++

 source from http://blog.csdn.net/steedhorse/article/details/333664

 

// Test.cpp   #include <iostream>  using namespace std;     class Base {   public:       void f() {           g();       }    private:       virtual void g() {           cout << "Hi, MorningStar! I am g() of Base!." << endl;       }   };    class Derived : public Base {   private:       virtual void g() {           cout << "Hi, MorningStar! I am g() of Derived." << endl;       }   };    int main() {       Base *pB = new Derived();       pB->f();       delete pB;       return 0;   }  

  

private virtual in c++