|
|
inserting class objects into maps
I know this is a simple question, so any help would be very much appreciated.
How do i insert a class into my map object along with a string as a key?
here is bit of my code.(Team is my class name)
///////////////////////////////////
Team myTeam();
map<string, Team> teams;
teams["teams"] = team;
/////////////////////////////
This returns a compile error.. how can i insert my class object into the map,
I tried using the pair<class T1, class T2> class, but my first argument is
a string not a class. therefore i can't use the insert() method from map.
thanx people
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
kichtr
|
9/13/2003 8:06:41 PM |
|
"Kieth" <kichtr@linuxmail.org> wrote in message
news:8c929d22.0309130751.4844d3a@posting.google.com...
> I know this is a simple question, so any help would be very
> much appreciated.
We can help you the most when you provide enough info to
understand your problem.
> How do i insert a class into my map object along with a
> string as a key?
>
> here is bit of my code.(Team is my class name)
> ///////////////////////////////////
>
> Team myTeam();
>
> map<string, Team> teams;
>
> teams["teams"] = team;
> /////////////////////////////
This could be the correct way to do it given a suitable
defintion of 'Team' and 'team'. But you don't give either,
so it's hard to say what the problem is.
> This returns a compile error..
*What* compile error?
> how can i insert my class object into the map, I tried using
> the pair<class T1, class T2> class, but my first argument is
> a string not a class.
The term 'class' when used as a template argument is a bit
of a misnomer, since it can match any non-template type.
> therefore i can't use the insert() method from map.
You can, but you need to provide more information before
anyone can show you how.
Dave
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
David
|
9/14/2003 1:36:34 AM
|
|
Kieth wrote:
> I know this is a simple question, so any help would be very much
> appreciated.
>
> How do i insert a class into my map object along with a string as a
> key?
>
> here is bit of my code.(Team is my class name)
> ///////////////////////////////////
>
> Team myTeam();
Declares a function named myTeam, which returns a Team object and takes not
arguments.
>
> map<string, Team> teams;
I suppose string is std::string.
> teams["teams"] = team;
Where is "team" coming from??? It is not defined anywhere.
> This returns a compile error.. how can i insert my class object into
> the map, I tried using the pair<class T1, class T2> class, but my
> first argument is
> a string not a class. therefore i can't use the insert() method from
> map. thanx people
Please post the *smallest* but still *complete* code which shows your
problem. The above code snippets show way too little and already way too
many (possible) errors.
--
WW aka Attila
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
White
|
9/14/2003 1:41:55 AM
|
|
|
2 Replies
530 Views
(page loaded in 0.015 seconds)
Similiar Articles: inserting class objects into maps - comp.lang.c++.moderated ...inserting class objects into maps - comp.lang.c++.moderated ... I know this is a simple question, so any help would be very much appreciated. How do i insert a class ... Problem inserting cell array using fastinsert() into mysql ...inserting class objects into maps - comp.lang.c++.moderated ... Problem inserting cell array using fastinsert() into mysql ... No method 'setInt ... class ... use MySQL as ... Write Depth Map to Depth buffer - comp.graphics.api.opengl ...Write Depth Map to Depth buffer - comp.graphics.api.opengl ... Hi, I'm writting a program that would insert a 3D object in a 2D scene. To ... inserting class objects into ... map of string to ostringstream - comp.lang.c++.moderated ...I'm using a map of strings to ostringstreams, and I'm trying to use map::insert ... inserting class objects into maps - comp.lang.c++.moderated ... map of string to ... Simple error : method format(String, Object[]) is not applicable ...inserting class objects into maps - comp.lang.c++.moderated ..... myTeam, which returns a Team object and takes not arguments. > > map<string ... renderbuffer objects - comp.graphics.api.openglinserting class objects into maps - comp.lang.c++.moderated ... renderbuffer objects - comp.graphics.api.opengl... SDK while using the FBO convenience class ... when you ... still struggling with FBOs and depth texture (for shadow map ...inserting class objects into maps - comp.lang.c++.moderated ..... map. thanx people Please post the *smallest* but still ... class ... when you want to create a shadow ... Sketch Picture Transparency - comp.cad.solidworksinserting class objects into maps - comp.lang.c++.moderated ... Inserting "Sketch Picture" with tranaprent backgroud? - comp.cad ... An Image object can be passed into the ... Best design for my classes to avoid code duplication? - comp.lang ...inserting class objects into maps - comp.lang.c++.moderated ... How do i insert a class into my map object along with a ... string as a key? > > here is bit of my code ... Why no std::back_insert_iterator::value_type? - comp.lang.c++ ...... changes I could safely format a char into any "iterator delimited stream". template <class Container> class back_insert ... modify map values through an iterator - comp ... inserting class objects into maps - comp.lang.c++.moderated ...inserting class objects into maps - comp.lang.c++.moderated ... I know this is a simple question, so any help would be very much appreciated. How do i insert a class ... C++ Inserting a class into a map container - Stack OverflowFirst, don't store objects themselves in the map, store pointers to your objects. Second, you need to give an instance of Scene_Branding to std::make_pair, not the ... 7/29/2012 4:22:02 PM
|
|
|
|
|
|
|
|
|