Advertisement
Guest User

Private virtual

a guest
Apr 5th, 2013
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. class Base {
  4.     public:
  5.         void doIt() {
  6.             std::cout << "Base::doIt()" << std::endl;
  7.             virtIt();
  8.         }
  9.     private:
  10.         virtual void virtIt() = 0;
  11. };
  12.  
  13. class Der: public Base {
  14.     public:
  15.         void tryThis() {
  16.             std::cout << "Der::tryThis()" << std::endl;
  17.             virtIt();
  18.         }
  19.     private:
  20.         void virtIt() {
  21.             std::cout << "Der::virtIt()" << std::endl;
  22.         }
  23. };
  24.  
  25. int main() {
  26.     Der d;
  27.     d.doIt();
  28.     d.tryThis();
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement