使用g++ -o test test.cpp编译程序c++程序时,由于使用了c++11的特性,所以在ubuntu下会报错如下:
test.cpp: In function ‘int main()’:
test.cpp:11:11: error: ‘inter’ does not name a type
for(auto inter=v.begin();inter!=v.end();inter++)
^
test.cpp:11:27: error: expected ‘;’ before ‘inter’
test.cpp: In function ‘int main()’:
test.cpp:11:11: error: ‘inter’ does not name a type
for(auto inter=v.begin();inter!=v.end();inter++)
^
test.cpp:11:27: error: expected ‘;’ before ‘inter’
for(auto inter=v.begin();inter!=v.end();inter++)
其实g++是支持c++11特性的,解决办法就是加上编译命令-std=c++11:
g++ -o test test.cpp -std=c++11