I'm a novice and work my way through Programming Principles and Practise using c++ by stroustrup ... I'm using Netbeans ide 8.1 and have a problem with the following:
#include "std_lib_facilities.h"
int main()
{
vector<int> v = {0,1,2,3,4,5,6};
for(int i = 0; i < v.size(); ++i)
cout << v[i] << "\n";
}
If I compile, I get the error could not convert {0, 1, 2, 3, 4, 5, 6}
from <brace-enclosed initializer list>
to Vector<int>
. I thought this has maybe something to do with missing compiler support for c++11
or 14, my compiler
is g++ 4.8
. Do I have to add anything to the compiler
settings or is it another problem? Thanks
为c ++ 14添加编译器标志-std = c ++ 14,为c ++ 11添加同样的-std = c ++ 11。仅将这些标志之一添加到IDE中的build标志。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.