I have created a class that contains a string and 2 integers in the private section. I want to use multiset to sort the strings, can i do this to a member of a class and will the two integers stay associated with each string?
I can give more explanation to the actual program if you want, it is a lot of code though.
Bottom line, i am using a multiset container to sort strings from a file then print them to another file, here is that code:
This all works good, but i would also like to associate each of the strings with 2 integers, so i thought a class might help. Any ideas?Code:ifstream formatin("format.txt"); ofstream sortout("sort.txt"); multiset <string> s; string word; while (formatin >> word) { s.insert(word); } multiset<string>::iterator p; for (p = s.begin(); p != s.end(); p++) { sortout << *p << " "; }
Thanks!
-quizkiwi



LinkBack URL
About LinkBacks


