fork download
  1. template< typename P >
  2. class A
  3. {
  4. private:
  5.  
  6. typedef A< P > TSelf;
  7.  
  8.  
  9. public:
  10. P m;
  11. TSelf( P f ) : m( f ){}
  12. };
  13.  
  14. class B : public A< int >
  15. {
  16. private:
  17. typedef A< int > TBase;
  18. public:
  19. B( int f ) : TBase( f ){}
  20. };
  21.  
  22. int main( void )
  23. {
  24. B lb( 8 );
  25. return ( 0 );
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:11:14: error: ISO C++ forbids declaration of 'TSelf' with no type
prog.cpp:11:25: error: declaration of 'int A<P>::TSelf(P)'
prog.cpp:6:18: error: conflicts with previous declaration 'typedef class A<P> A<P>::TSelf'
prog.cpp: In member function 'int A<P>::TSelf(P)':
prog.cpp:11:18: error: only constructors take base initializers
prog.cpp: At global scope:
prog.cpp: In instantiation of 'A<int>':
prog.cpp:15:1:   instantiated from here
prog.cpp:10:5: error: declaration of 'int A<P>::TSelf(P) [with P = int]'
prog.cpp:6:18: error: conflicts with previous declaration 'typedef class A<int> A<int>::TSelf'
prog.cpp: In constructor 'B::B(int)':
prog.cpp:19:25: error: no matching function for call to 'A<int>::A(int&)'
prog.cpp:3:1: note: candidates are: A<int>::A()
prog.cpp:3:1: note:                 A<int>::A(const A<int>&)
stdout
Standard output is empty