fork(1) 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. s._method( s);
  12. }
  13.  
  14. protected:
  15. virtual void _method( const Self & b) = 0;
  16. };
  17.  
  18. class _B;
  19.  
  20.  
  21. template< typename Self=_B>
  22. class B : public A< Self> {
  23.  
  24. protected:
  25. void _method( const Self & b) {}
  26. };
  27.  
  28. class _B : public B< > { };
  29.  
  30. int main() {
  31. B<>().foo();
  32.  
  33. return 0;
  34. }
Compilation error #stdin compilation error #stdout 0s 3292KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘void A<Self>::foo() [with Self = _B]’:
prog.cpp:31:15:   required from here
prog.cpp:25:10: error: ‘void B<Self>::_method(const Self&) [with Self = _B]’ is protected
     void _method( const Self & b) {}
          ^
prog.cpp:11:6: error: within this context
      s._method( s);
      ^
stdout
Standard output is empty