Advertisement
karlicoss

ололо

Jun 19th, 2011
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. template <typename T>
  2. class Base
  3. {
  4. public:
  5.     void exit()
  6.     {
  7.         cout << "exit was called" << endl;
  8.     }
  9. };
  10.  
  11. template <typename T>
  12. class Derived: Base<T>
  13. {
  14. public:
  15.     void foo()
  16.     {
  17.         exit();        // Вызов внешней функции exit() или ошибка!
  18.         this->exit();  // Корректно.
  19.     }
  20. };
  21.  
  22. int main()
  23. {
  24.     Derived<int> d;
  25.     d.foo();
  26.     return 0;
  27. }
  28. //это выводит exit was called два раза, как и ожидалось
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement