fork(1) download
  1. #include <iostream>
  2.  
  3. #include <vector>
  4. #include <iterator>
  5.  
  6.  
  7. template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
  8. class PtrVector
  9. {
  10. private:
  11. typedef std::vector<_Tp, _Alloc> VectrorT;
  12. typedef typename std::vector<_Tp, _Alloc> VT;
  13.  
  14. public:
  15.  
  16. typename std::vector<_Tp, _Alloc>::const_iterator test(){}
  17. VT::const_iterator test2(){} // why there is error here?
  18.  
  19. };
  20.  
  21.  
  22. int main() {
  23. return 0;
  24. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:17:5: error: need ‘typename’ before ‘PtrVector<_Tp, _Alloc>::VT::const_iterator’ because ‘PtrVector<_Tp, _Alloc>::VT’ is a dependent scope
     VT::const_iterator test2(){} // why there is error here?
     ^
stdout
Standard output is empty