请问c + +有一个像列表与LT任何东西;串>在C#中? [英] Does C++ have anything like List<string> in C#?
本文介绍了请问c + +有一个像列表与LT任何东西;串>在C#中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请问C ++有像什么名单,LT;>
在C#中?类似列表<字符串方式>
存储字符串数组
Does C++ has anything like List<>
in C#? Something like List<string>
for storing an array of strings.
推荐答案
其实答案
std::vector<std::string>
的std ::列表
是一个链表,没有像C#的数组列表< T>
类
std::list
is a linked list, not an array like C#'s List<T>
class.
例如:
#include <iostream> // iostream is for cout and endl; not necessary just to use vector or string
#include <vector>
#include <string>
using namespace std;
int main()
{
vector<string> list;
list.push_back("foo");
list.push_back("bar");
for( vector<string>::const_iterator it = list.begin(); it != list.end(); ++it )
cout << *it << endl;
return 0;
}
的
的std ::列表
类其实就相当于C#的的LinkedList< T>
类
The std::list
class is actually equivalent to C#'s LinkedList<T>
class.
这篇关于请问c + +有一个像列表与LT任何东西;串>在C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文