注册 登录
编程论坛 C++教室

一个关于C++中vector方面的问题

lxqlyld 发布于 2012-07-09 17:24, 397 次点击
我在书上看到一个程序片段:
typedef vector<string> textwords;
vector<textwords>tvc;
请问各位高手,把vector定义成这种复合情形有什么作用
4 回复
#2
lonmaor2012-07-09 19:59
定义一个vector对象tvc,每个成员是textwords类型的对象。
textwords类型的对象是什么呢? vector<string>
#3
nayizhan2012-07-09 22:18
textwords是vector<string>的别名。
#4
lxqlyld2012-07-10 09:08
回复 2楼 lonmaor
tvc的类型是textwords,这个我知道,我想问一下,将tvc定义成这种类型vector<vector<string>>tvc,有什么作用,在什么情况下需要声明成这种情况
#5
lonmaor2012-07-10 10:51
比如,vector<string> 建立了一个存储单词的容器
vector<textwords> tvc; 则建立了一个存储句子的容器,不要忘了,句子是由单词组成的。
1