Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > map of objects

Reply
Thread Tools

map of objects

 
 
DerekBaker
Guest
Posts: n/a
 
      04-19-2008
Why given this:

C c(5, 6, 7); // C has two ctors: one takes 3 ints, one a single int.
map<int, C> TestMap;

is this ok?

TestMap.insert(make_pair(1, c));

but not this?

TestMap[1] = c;

Thanks
--
Derek
 
Reply With Quote
 
 
 
 
DerekBaker
Guest
Posts: n/a
 
      04-19-2008
* DerekBaker:
> Why given this:
>
> C c(5, 6, 7); // C has two ctors: one takes 3 ints, one a single int.
> map<int, C> TestMap;
>
> is this ok?
>
> TestMap.insert(make_pair(1, c));
>
> but not this?
>
> TestMap[1] = c;
>
> Thanks


Never mind, should have read my Josuttis first. Adding a default constructor works fine.

--
Derek
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
std::map::find() throws exception when map is empty? Matthias Hildebrand C++ 5 03-20-2012 06:09 AM
class objects, method objects, function objects 7stud Python 11 03-20-2007 06:05 PM
I can map all files (.*) to asp.net worker.How do I map NO FILE to asp.net worker? alex ASP .Net 1 02-04-2005 03:18 AM
map.insert(key,val) vs. map[key]=val ? Patrick Guio C++ 6 10-20-2004 01:54 PM
map that maps to iterators in the same map ? Vlad C++ 0 12-15-2003 08:29 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57