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

前端 未结 2 1696
谎友^
谎友^ 2021-01-13 04: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: vect

相关标签:
2条回答
  • 2021-01-13 04:55

    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.

    0 讨论(0)
  • 2021-01-13 04:57

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

    vector<set<char> > testVect;
    
    0 讨论(0)
提交回复
热议问题