fork(2) download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. template< typename Self>
  7. class A {
  8. public:
  9. void foo( ) {
  10. Self s;
  11. ( ( A< Self> &) s)._method( s);
  12. }
  13.  
  14. protected:
  15. virtual void _method( const Self & b) = 0;
  16. };
  17.  
  18. class _B;
  19.  
  20.  
  21. class B : public A< B> {
  22.  
  23. protected:
  24. void _method( const B & b) { cout << "goo!"; }
  25. };
  26.  
  27. int main() {
  28. B().foo();
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
goo!