ubuntu下c++11的支持问题

来源:互联网 发布:python rqalpha 编辑:程序博客网 时间:2024/05/16 13:40
使用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’

  for(auto inter=v.begin();inter!=v.end();inter++)

其实g++是支持c++11特性的,解决办法就是加上编译命令-std=c++11:

g++ -o test test.cpp -std=c++11


0 0
原创粉丝点击