Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi!
Thanks always for all the help.
Today I would like to ask about sets and multisets from the STL of C++.
If I have a class such as:
class Aclass
{private:
int theKey;
float theData;
};----------------
and I would like to use objects from it in a multiset how can I do it?I read the sintax of MultiSets (and sets too) is
multiset<Key, compareF>
----------------
and that for sets of ints or doubles this compareF usually is not neccesary to be specified. But for sets of objects or pointer to objects what else should I do???
I am thinking the following is not enough:
typedef std::multiset<Aclass> TsetOfClasses;
----------------
ortypedef std::multiset<Aclass *> TPsetOfClasses;
----------------
I read in the documentation that a key comparison function should be provided.
Please help me
(by the way, I know that in this particular case a Map would be better, but I am interested in using sets because in a method the object has to have access to the key and with maps that is not possible)

![]() |
C++ array of buttons
|
mouse position determinat...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |