map pass by refrence?

This is a discussion on map pass by refrence? within the C++ Programming forums, part of the General Programming Boards category; Can I pass a map by refrence to a function ie: Code: MainMenu::MainMenu(std::map<string,Book> rlibrary &){ ptrLibrary=rlibrary; while(Menu::get_option()!=6){ while (!(validate_option(Menu::get_option()))){ display_menu(); ...

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    450

    Post map pass by refrence?

    Can I pass a map by refrence to a function
    ie:
    Code:
    MainMenu::MainMenu(std::map<string,Book> rlibrary &){
        ptrLibrary=rlibrary;
        while(Menu::get_option()!=6){
            while (!(validate_option(Menu::get_option()))){
                    display_menu();
                    Menu::set_option(Menu::input_option());
            }
            process_option(Menu::get_option());
        }
    }

  2. #2
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Yes, but you've used the wrong syntax. This is correct:
    Code:
    MainMenu::MainMenu(std::map<string,Book> &  rlibrary){
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    450
    Thanks this programming is definitly a learning experience.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Polynomials and ADT's
    By Emeighty in forum C++ Programming
    Replies: 20
    Last Post: 08-19-2008, 08:32 AM
  2. Speed test result
    By audinue in forum C Programming
    Replies: 4
    Last Post: 07-07-2008, 05:18 AM
  3. Creating a map engine.
    By suzakugaiden in forum Game Programming
    Replies: 11
    Last Post: 06-21-2005, 05:06 AM
  4. pass by refrence help.
    By Harman in forum C Programming
    Replies: 2
    Last Post: 05-11-2005, 08:27 PM
  5. Searching STL Map Inside STL Map Object :: C++
    By kuphryn in forum C++ Programming
    Replies: 2
    Last Post: 11-14-2002, 08:11 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21