fork download
  1. #define _DEFINE_DEPRECATED_HASH_CLASSES 0
  2. #include <bits/stdc++.h>
  3. //#include <hash_set>
  4.  
  5. using namespace std;
  6. using namespace stdext;
  7.  
  8. int main
  9. {
  10. hashset <int> hs1;
  11. hashset <int>::iterator hs1_Iter;
  12. hashset <int>::const_iterator hs1_cIter;
  13.  
  14. hs1.insert( 1 );
  15. hs1.insert( 2 );
  16. hs1.insert( 3 );
  17.  
  18. hs1_Iter = hs1.begin( );
  19. cout <<"The first element of hs1 is "<<*hs1_Iter<<endl;
  20.  
  21. hs1_Iter = hs1.begin( );
  22. hs1.erase( hs1_Iter );
  23.  
  24. // The following 2 lines would err because the iterator is const
  25. // hs1_cIter = hs1.begin( );
  26. // hs1.erase( hs1_cIter );
  27.  
  28. hs1_cIter = hs1.begin( );
  29. cout <<"The first element of hs1 is now "<<*hs1_cIter<<endl;
  30.  
  31. return 0;
  32. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:6:17: error: 'stdext' is not a namespace-name
 using namespace stdext;
                 ^
prog.cpp:6:23: error: expected namespace-name before ';' token
 using namespace stdext;
                       ^
prog.cpp:9:1: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
 {
 ^
prog.cpp:10:3: error: 'hashset' was not declared in this scope
   hashset <int> hs1;
   ^
prog.cpp:10:12: error: expected primary-expression before 'int'
   hashset <int> hs1;
            ^
prog.cpp:10:12: error: expected '}' before 'int'
prog.cpp:10:12: error: expected ',' or ';' before 'int'
prog.cpp:11:3: error: 'hashset' does not name a type
   hashset <int>::iterator hs1_Iter;
   ^
prog.cpp:12:3: error: 'hashset' does not name a type
   hashset <int>::const_iterator hs1_cIter;
   ^
prog.cpp:14:3: error: 'hs1' does not name a type
   hs1.insert( 1 );
   ^
prog.cpp:15:3: error: 'hs1' does not name a type
   hs1.insert( 2 );
   ^
prog.cpp:16:3: error: 'hs1' does not name a type
   hs1.insert( 3 );
   ^
prog.cpp:18:3: error: 'hs1_Iter' does not name a type
   hs1_Iter = hs1.begin( );
   ^
prog.cpp:19:3: error: 'cout' does not name a type
   cout <<"The first element of hs1 is "<<*hs1_Iter<<endl;
   ^
prog.cpp:21:3: error: 'hs1_Iter' does not name a type
   hs1_Iter = hs1.begin( );
   ^
prog.cpp:22:3: error: 'hs1' does not name a type
   hs1.erase( hs1_Iter );
   ^
prog.cpp:28:3: error: 'hs1_cIter' does not name a type
   hs1_cIter = hs1.begin( );
   ^
prog.cpp:29:3: error: 'cout' does not name a type
   cout <<"The first element of hs1 is now "<<*hs1_cIter<<endl;
   ^
prog.cpp:31:3: error: expected unqualified-id before 'return'
   return 0;
   ^
prog.cpp:32:1: error: expected declaration before '}' token
 }
 ^
stdout
Standard output is empty