为什么我需要包含< vector>使用它们? [英] why do i need to include <vector> to use them?
问题描述
我是C ++的新手,试图弄清楚如何使用 vector
.
I am new to C++ and trying to figure out how to use vector
.
更具体地说,我想知道何时需要使用#include< vector>
.我之所以这么问,是因为我看到过带有和不带有 #include
语句的程序,它们在程序中使用 vector
.
More specifically, I want to know when I need to use #include<vector>
. I am asking that because I have seen programs with and without the #include
statement that use vector
in the program.
推荐答案
当您看到使用 std :: vector
而不使用 #include< vector>
的代码>,该代码已损坏.期间.
When you see code that uses std::vector
, but did not #include <vector>
, that code is broken. Period.
在特定的编译器/标准库实现/平台/行星上工作可能恰好发生",这取决于哪些其他恰好发生"的标准头文件已经包含了< vector>
供自己使用.不得依赖.
It may "just so happen" to work on particular compilers/standard library implementations/platforms/planets, depending on which other standard headers "just so happen" to already be including <vector>
for their own use. This shall not be relied upon.
这篇关于为什么我需要包含< vector>使用它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!