C++ Maps

This is a discussion on C++ Maps within the C++ Programming forums, part of the General Programming Boards category; How would I implement a map with more than 1 key, for example, to retrieve a customer's name based on ...

  1. #1
    Unregistered
    Guest

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

    thanks

  2. #2
    Registered User Strider's Avatar
    Join Date
    Aug 2001
    Posts
    149
    Use a struct to contain the data for the key:
    Code:
    typedef struct
    {
        unsigned int        uiHouseNumber;
        char                pcStreetName[255];
    } Address;
    
    typedef map<Address, string, less<Address>, allocator> Customer;
    David
    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, 11:09 AM
  2. Hash_map, STL maps query
    By alvifarooq in forum C++ Programming
    Replies: 15
    Last Post: 06-07-2005, 10: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 Cprogramming.com
    Replies: 3
    Last Post: 09-25-2001, 08:44 PM

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