【发布时间】:2016-10-02 17:18:06
【问题描述】:
所以,在这里我只想定义一个向量,然后打印向量当前状态的大小,但是 dev c/c++ 中的编译器给了我一个编译时错误,“向量没有在 scope() 中声明” "
我想知道我是否没有包含正确的头文件或其他东西。
#include<iostream>
using namespace std;
int main()
{
vector<int> v(6); //defining the vector
cout<<"Size= "<<v.size(); //printing the present size of the vector
return 0;
}
【问题讨论】:
-
#include <vector>是通往Warp drive 的正确道路。 -
“我想知道我是否没有包含正确的头文件”并且您认为在这里花几分钟问一个问题比花几秒钟看docs of
std::vector更有效? -
我是 C++ 新手,所以我问。这可能看起来很傻,但是,嘿,什么问题不呢?