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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CMap problem

CMap problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 3 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.
  • W Offline
    W Offline
    Worried
    wrote on last edited by
    #1

    I am using a CMap CMap my_map; my_map.SetAt("abc",1); my_map.SetAt("xyz",22); ... I need this map to be globaly accessible in my application, therefore I am initialising this in a common header file of my application. But when i compile the coe I get following errors: : error C2143: syntax error : missing ';' before '.' : error C2501: 'my_map' : missing storage-class or type specifiers : error C2371: 'my_map' : redefinition; different basic types : see declaration of 'my_map' Any pointers?

    P T 2 Replies Last reply
    0
    • W Worried

      I am using a CMap CMap my_map; my_map.SetAt("abc",1); my_map.SetAt("xyz",22); ... I need this map to be globaly accessible in my application, therefore I am initialising this in a common header file of my application. But when i compile the coe I get following errors: : error C2143: syntax error : missing ';' before '.' : error C2501: 'my_map' : missing storage-class or type specifiers : error C2371: 'my_map' : redefinition; different basic types : see declaration of 'my_map' Any pointers?

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      ~Worried! wrote:

      error C2143: syntax error : missing ';' before '.' : error C2501: 'my_map' : missing storage-class or type specifiers

      CMap is declared in afxtempl.h, you need to include that file.

      ~Worried! wrote:

      I need this map to be globaly accessible in my application, therefore I am initialising this in a common header file of my application.

      In this case, use extern. In common header,

      extern CMap my_map;

      And in one on cpp file define it. i.e.

      CMap my_map;

      Prasad Notifier using ATL | Operator new[],delete[][^]

      W 1 Reply Last reply
      0
      • W Worried

        I am using a CMap CMap my_map; my_map.SetAt("abc",1); my_map.SetAt("xyz",22); ... I need this map to be globaly accessible in my application, therefore I am initialising this in a common header file of my application. But when i compile the coe I get following errors: : error C2143: syntax error : missing ';' before '.' : error C2501: 'my_map' : missing storage-class or type specifiers : error C2371: 'my_map' : redefinition; different basic types : see declaration of 'my_map' Any pointers?

        T Offline
        T Offline
        ThatsAlok
        wrote on last edited by
        #3

        ~Worried! wrote:

        CMap my_map;

        where is key value pair

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

        W 1 Reply Last reply
        0
        • P prasad_som

          ~Worried! wrote:

          error C2143: syntax error : missing ';' before '.' : error C2501: 'my_map' : missing storage-class or type specifiers

          CMap is declared in afxtempl.h, you need to include that file.

          ~Worried! wrote:

          I need this map to be globaly accessible in my application, therefore I am initialising this in a common header file of my application.

          In this case, use extern. In common header,

          extern CMap my_map;

          And in one on cpp file define it. i.e.

          CMap my_map;

          Prasad Notifier using ATL | Operator new[],delete[][^]

          W Offline
          W Offline
          Worried
          wrote on last edited by
          #4

          prasad_som wrote:

          CMap is declared in afxtempl.h, you need to include that file.

          Even then the error does not go. Actually there is no seperate .cpp file here. This header file contains all the constants etc required in my app. I just want to associate some key-value pairs so that they can be searched some time later in the applicataion.

          1 Reply Last reply
          0
          • T ThatsAlok

            ~Worried! wrote:

            CMap my_map;

            where is key value pair

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

            W Offline
            W Offline
            Worried
            wrote on last edited by
            #5

            ThatsAlok wrote:

            where is key value pair

            In the same header file.

            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