如何在C ++中执行集合向量? [英] How to do the vector of sets in C++?
问题描述
我可以做一个简单的集合数组:
set < char > * words = new set < char > [10]
我怎样做向量集?
这导致编译器错误:
vector < set< char >> v
.
谢谢您的回答!
I can do a simple array of sets:
set < char > * words = new set < char > [10]
How I can do a vector of sets?
This results in a compiler error:
vector < set< char >> v
.
Thank you for answers!
推荐答案
如果vector < set< char >> v
正是您所拥有的(我希望您剪切并粘贴),则您遇到了一个令人讨厌的小功能之一C ++.
If vector < set< char >> v
is exactly what you've got there (I hope you cut and pasted), you've run into one of the annoying little features of C++.
那些>>
在您看来就像是两个模板的两个闭合尖括号.对于编译器,它们看起来像是右移运算符.将它们更改为> >
,并在两者之间留一个空格.
Those >>
look to you like two closing angle brackets for two templates. They look like a right shift operator to the compiler. Change them to > >
with a space in between.
幸运的是,这一问题已在今年应批准的C ++标准中得到解决.不幸的是,您现在还没有使用兼容C ++ 11的编译器.
Fortunately, this is being addressed in the C++ standard that should be ratified this year. Unfortunately, you aren't working with a C++11-compliant compiler just now.
这篇关于如何在C ++中执行集合向量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!