2 c++ python arrays list c++-standard-library
我正在学习来自python背景的c ++.
我想知道有没有办法将项目附加到c ++列表中?
myList = []
for i in range(10):
myList.append(i)
Run Code Online (Sandbox Code Playgroud)
在c ++中你可以对数组做些什么吗?
你需要一个矢量,做这样的事情:
#include <vector>
void funct() {
std::vector<int> myList;
for(int i = 0; i < 10; i++)
myList.push_back(10);
}
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参见http://cplusplus.com/reference/stl/vector/.