简体   繁体   English

C++ 中的初始化向量

[英]Initialising vector in C++

I'm initialising vector using the below method我正在使用以下方法初始化向量

vector<int> num1{1, 9, 3, 7, 0, 7, 7, 2, 1};

and it is throwing error as below,它抛出如下错误,

Multiplication.cpp:29:18: error: expected ';' at end of declaration
        vector<int> num1{1, 9, 3, 7, 0, 7, 7, 2, 1};
                        ^

You haven't included the vector library, just add您还没有包含矢量库,只需添加

#include<vector>

at the top of your code在代码的顶部

it is running check here在这里运行检查

if you did that too, then too, it is a compiler problem, try using a different complier or online complier like ideone如果您也这样做了,那也是编译器问题,请尝试使用不同的编译器或像 ideone 这样的在线编译器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM