Per*_*nce 2 c++ compiler-errors
好吧,当涉及到C++(从VB转移过来)时,我是一个新手,我似乎无法解决如何在不执行的情况下填充数组:
array[0] = 1
array[1] = 2
Run Code Online (Sandbox Code Playgroud)
等等
正如可以预料的那样,我试过这个:
float posVector[3]; //Declared outside of int main() as needs to be global
posVector = {0.0f,0.0f,0.0f}; //Inside int main()
Run Code Online (Sandbox Code Playgroud)
这导致显示此错误:
extended initializer lists only available with -std=c++0x or -std=gnu++0x [enabled by default]
Run Code Online (Sandbox Code Playgroud)
到目前为止,我无法在网上找到任何帮助.所以,任何建议,你可以给我修复这个将不胜感激!
声明数组后,无法使用初始化列表初始化它.你可以去
float posVector[] = {0.0f,0.0f,0.0f};
Run Code Online (Sandbox Code Playgroud)
或者更好地使用std :: vector:
#include <vector>
std::vector<float> posVector = {0.0f,0.0f,0.0f};
Run Code Online (Sandbox Code Playgroud)