+ 1
i cant figure out how to put a vector into a multiset. i need the multiset to have <char,int> signature.
#include <iostream> #include <vector> #include <set> #include <cstdlib> #include <algorithm> #include <iterator> int main(){ std::vector<int> v(3200,rand()%100); std::multiset<char,int> mset; std::multiset<char,int>::iterator msetIt; std::cout<<"copied vector v to multiset mset: "<<std::endl; cpyVecToMSet(v); for(msetIt;msetIt != mset.end();msetIt++){ std::cout<<*msetIt<<" "; }; return 0; } std::multiset<char,int> cpyVecToMSet(std::vector<int> &vect){ std::multiset<char, int> tmpMSet(vect.begin(),vect.end()); return tmpMSet; };
1 ответ
0
Bro, i think you got the multiset constructor wrong. It's multiset<int, function> . Look into pair<char,int>, as multiset<pair<char,int>> .
website: www.cplusplus.com