Im trying to compile this code via g++,
#include <iostream>
#include <set>
using namespace std;
std::set<int> s;
int main(){
for(int i=0;i<10;i++) s.insert(i);
for(auto target: s){
cout<<target<<endl;
}
return 0;
}
but g++ 4.8 gives me this error:
ali@Melkor ~/Desktop/Project $ g++ a.cpp
a.cpp: In function ‘int main()’:
a.cpp:10:10: error: ‘target’ does not name a type
for(auto target: s){
^
a.cpp:14:1: error: expected ‘;’ before ‘return’
return 0;
^
a.cpp:14:1: error: expected primary-expression before ‘return’
a.cpp:14:1: error: expected ‘;’ before ‘return’
a.cpp:14:1: error: expected primary-expression before ‘return’
a.cpp:14:1: error: expected ‘)’ before ‘return’
ali@Melkor ~/Desktop/Project $
Is there anything wrong with my code?