Computing.Net > Forums > Programming > Set, multiset (STL) C++

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Set, multiset (STL) C++

Reply to Message Icon

Name: Pukara
Date: February 29, 2004 at 03:31:36 Pacific
OS: Linux
CPU/Ram: .
Comment:

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;

----------------
or

typedef 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)




Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


C++ array of buttons mouse position determinat...



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Set, multiset (STL) C++

setting up borland c++ compiler 2K www.computing.net/answers/programming/setting-up-borland-c-compiler-2k/7324.html

Visual c++ 6.0 www.computing.net/answers/programming/visual-c-60/81.html

C++ Question www.computing.net/answers/programming/c-question/6817.html