Thread: C++ Maps

  1. #1

    Question C++ Maps

    How would I implement a map with more than 1 key, for example, to retrieve a customer's name based on their address, using the house number as 1 key and the street name as another. (the 2 keys put together should be unique) ??


  2. #2
    Registered User Strider's Avatar
    Join Date
    Aug 2001
    Use a struct to contain the data for the key:
    typedef struct
        unsigned int        uiHouseNumber;
        char                pcStreetName[255];
    } Address;
    typedef map<Address, string, less<Address>, allocator> Customer;
    One Ring to rule them all, One Ring to find them,
    One Ring to bring them all and in the darkness bind them
    In the Land of Mordor where the Shadows lie.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Loading maps
    By divineleft in forum C++ Programming
    Replies: 1
    Last Post: 07-05-2006, 10:09 AM
  2. Hash_map, STL maps query
    By alvifarooq in forum C++ Programming
    Replies: 15
    Last Post: 06-07-2005, 09:07 AM
  3. DDX/DDV and Message Maps
    By axr0284 in forum Windows Programming
    Replies: 2
    Last Post: 01-07-2005, 08:55 AM
  4. maps as reference?
    By robquigley in forum C++ Programming
    Replies: 2
    Last Post: 11-26-2003, 09:12 AM
  5. Finding terrain maps...
    By VirtualAce in forum A Brief History of
    Replies: 3
    Last Post: 09-25-2001, 07:44 PM