Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. data map declartion.

data map declartion.

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CodingLover
    wrote on last edited by
    #1

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

    K 1 Reply Last reply
    0
    • C CodingLover

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

      K Offline
      K Offline
      Karismatic
      wrote on last edited by
      #2

      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

      C D 2 Replies Last reply
      0
      • K Karismatic

        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

        C Offline
        C Offline
        CodingLover
        wrote on last edited by
        #3

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

        J 1 Reply Last reply
        0
        • C CodingLover

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

          J Offline
          J Offline
          jhwurmbach
          wrote on last edited by
          #4

          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"

          1 Reply Last reply
          0
          • K Karismatic

            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

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups