Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 541
Zhake Avatar asked Apr 08 '11 19:04

Zhake


2 Answers

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.

like image 66
David Thornley Avatar answered Oct 01 '22 03:10

David Thornley


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

vector<set<char> > testVect;
like image 36
poy Avatar answered Oct 01 '22 04:10

poy