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. return a map from a function

return a map from a function

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

    Im using a map to store data.So i want to return the map. map* RSUserControlContainer::GetAnswers() { //UserControlInfo is a structure map mapAnswers = new map; --------------- --------------------------//Other code ----------------------------------- return mapAnswers ; } But It give some errors.So how can i return a map from a function. bhw

    T R M H 4 Replies Last reply
    0
    • T TobetheWinner

      Im using a map to store data.So i want to return the map. map* RSUserControlContainer::GetAnswers() { //UserControlInfo is a structure map mapAnswers = new map; --------------- --------------------------//Other code ----------------------------------- return mapAnswers ; } But It give some errors.So how can i return a map from a function. bhw

      T Offline
      T Offline
      TobetheWinner
      wrote on last edited by
      #2

      some syntax i typed here is not visible when i post it.map means map C++ map. bhw

      R D 2 Replies Last reply
      0
      • T TobetheWinner

        Im using a map to store data.So i want to return the map. map* RSUserControlContainer::GetAnswers() { //UserControlInfo is a structure map mapAnswers = new map; --------------- --------------------------//Other code ----------------------------------- return mapAnswers ; } But It give some errors.So how can i return a map from a function. bhw

        R Offline
        R Offline
        Rajkumar R
        wrote on last edited by
        #3

        Hi, map mapAnswers, is not the pointer, Do you forgot it.

        1 Reply Last reply
        0
        • T TobetheWinner

          Im using a map to store data.So i want to return the map. map* RSUserControlContainer::GetAnswers() { //UserControlInfo is a structure map mapAnswers = new map; --------------- --------------------------//Other code ----------------------------------- return mapAnswers ; } But It give some errors.So how can i return a map from a function. bhw

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          TobetheWinner wrote:

          But It give some errors.

          What errors?

          --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Dunder-Mifflin, this is Pam.

          1 Reply Last reply
          0
          • T TobetheWinner

            some syntax i typed here is not visible when i post it.map means map C++ map. bhw

            R Offline
            R Offline
            Rajkumar R
            wrote on last edited by
            #5

            use <pre>, <, > symbols from formatting option when you compose the post

            1 Reply Last reply
            0
            • T TobetheWinner

              Im using a map to store data.So i want to return the map. map* RSUserControlContainer::GetAnswers() { //UserControlInfo is a structure map mapAnswers = new map; --------------- --------------------------//Other code ----------------------------------- return mapAnswers ; } But It give some errors.So how can i return a map from a function. bhw

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              But you didnt say any thing about errors.


              WhiteSky


              1 Reply Last reply
              0
              • T TobetheWinner

                some syntax i typed here is not visible when i post it.map means map C++ map. bhw

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

                map<int ,UserControlInfo>* RSUserControlContainer::GetAnswers()
                {
                //UserControlInfo is a structure
                map<int, AnswerType> mapAnswers = new map<int, AnswerType>;
                return mapAnswers ;
                }

                The compiler is probably complaining about returning an AnswerType map when the function's return type specifies a UserControlInfo map.


                "A good athlete is the result of a good and worthy opponent." - David Crow

                "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