A
ambarish.mitra
Hi all,
I have a multimap, where key is an int and the value is a class. I can
insert into the multimap, but finding it difficult to retrieve the
value when keys match. I can do this with primitive types (int/char
etc).
Example:
class A {
public:
int vol;
int temp;
};
multimap<int, A> mechanics;
multimap<int, A>::iterator it;
A aobj;
aobj.vol=10;
aobj.temp=20;
mechanics.insert(pair<int, A>(5, aobj));
// many insert statements here....
std:air<multimap<int,A>::iterator,multimap<int,A>::iterator> ret;
ret = mechanics.equal_range(5);
for (it=ret.first; it!=ret.second; ++it)
// How to read the object that matches the key in the multimap?
;
Upto this is okay, but then how can I find out the object
corresponding to the given key in the multimap?
Any help/pointers?
Regards.
I have a multimap, where key is an int and the value is a class. I can
insert into the multimap, but finding it difficult to retrieve the
value when keys match. I can do this with primitive types (int/char
etc).
Example:
class A {
public:
int vol;
int temp;
};
multimap<int, A> mechanics;
multimap<int, A>::iterator it;
A aobj;
aobj.vol=10;
aobj.temp=20;
mechanics.insert(pair<int, A>(5, aobj));
// many insert statements here....
std:air<multimap<int,A>::iterator,multimap<int,A>::iterator> ret;
ret = mechanics.equal_range(5);
for (it=ret.first; it!=ret.second; ++it)
// How to read the object that matches the key in the multimap?
;
Upto this is okay, but then how can I find out the object
corresponding to the given key in the multimap?
Any help/pointers?
Regards.