data map declartion.
-
Hi all, I'm working with a map to store a string, int pair. I want to make my code more clear. So I'm try to define my map in a common place and use to store data on it. So where should I declare the map. I've try to define in the class definition file(class header file), but in the data insertion statement I got the following error.
error C2678: binary '[' : no operator found which takes a left-hand operand of type 'const std::map<_Kty,_Ty>' (or there is no acceptable conversion)
I've declared the map as follows,map data_map;
How can I solved this.I appreciate your help all the time... Eranga :)
-
Hi all, I'm working with a map to store a string, int pair. I want to make my code more clear. So I'm try to define my map in a common place and use to store data on it. So where should I declare the map. I've try to define in the class definition file(class header file), but in the data insertion statement I got the following error.
error C2678: binary '[' : no operator found which takes a left-hand operand of type 'const std::map<_Kty,_Ty>' (or there is no acceptable conversion)
I've declared the map as follows,map data_map;
How can I solved this.I appreciate your help all the time... Eranga :)
Firstly map not declared as map data_map; if you have to store an int & a string inside the map then declaration will be like this: - map< int,std::string > data_map; In this the integer filed will be your primary field and corresspoding to which you get the data.
Regards, Pankaj Sachdeva There is no future lies in any job but future lies in the person who holds the job
-
Firstly map not declared as map data_map; if you have to store an int & a string inside the map then declaration will be like this: - map< int,std::string > data_map; In this the integer filed will be your primary field and corresspoding to which you get the data.
Regards, Pankaj Sachdeva There is no future lies in any job but future lies in the person who holds the job
Oops, Really sorry about that. Miss the middle part of the code, may be because of the code tags. Its like this, map data_map
I appreciate your help all the time... Eranga :)
-
Oops, Really sorry about that. Miss the middle part of the code, may be because of the code tags. Its like this, map data_map
I appreciate your help all the time... Eranga :)
Eranga Thennakoon wrote:
Really sorry about that. Miss the middle part of the code, may be because of the code tags.
Oops you did it again! :) Use the pre-Tag to enclose the code or use the < > tags instead of the one on your keyboard. You'll find them below the text editor when writing the message!
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all.
Douglas Adams, "Dirk Gently's Holistic Detective Agency" -
Firstly map not declared as map data_map; if you have to store an int & a string inside the map then declaration will be like this: - map< int,std::string > data_map; In this the integer filed will be your primary field and corresspoding to which you get the data.
Regards, Pankaj Sachdeva There is no future lies in any job but future lies in the person who holds the job
Karismatic wrote:
Firstly map not declared as map data_map;
His map is declared as:
map<string, int=""> data_map;
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne