fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<typename T>
  5. class A {
  6. public:
  7. // void test() {
  8. // cout << "A::test" << endl;
  9. // }
  10.  
  11. void callTest() {
  12. static_cast<T *>(this)->test();
  13. }
  14. };
  15.  
  16. class B : public A<B> {
  17. public:
  18. void test() {
  19. cout << "B::test" << endl;
  20. }
  21. };
  22.  
  23. int main() {
  24. B b;
  25. b.callTest();
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 4452KB
stdin
Standard input is empty
stdout
B::test