How to do the vector of sets in C++?

不羁岁月 提交于 2019-12-01 03:38:29

问题


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!


回答1:


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.

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.




回答2:


Instead of '>>' try '> >'... like so:

vector<set<char> > testVect;


来源:https://stackoverflow.com/questions/5599642/how-to-do-the-vector-of-sets-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!