map<int ,std::string>

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • darkkal
    New Member
    • Oct 2007
    • 2

    map<int ,std::string>

    Hi I'm a student majoring a computer .

    I tried to make a simple hashing table like (int) 1 , (std::string) "One"
    There is a problem in using std::map ㅜㅜ


    this is a simple code.
    PLZ~~Help me :)

    [CODE=cpp]#include <iostream>
    #incluce <map>

    int main()
    {

    std::map<int ,std::string> test ;
    test.insert(std ::make_pair(1," as"));
    test.insert(std ::make_pair(2," as"));

    std::map<int,st d::string>::ite rator start = test.begin();
    std::map<int,st d::string>::ite rator last = test.end();
    for(start ; start != last ; ++start )
    {
    std::cout << start->first ;
    std::cout << "\t" ;
    // std::cout << start->second <<std::endl; //it does not work
    }
    }[/CODE]

    Thank you^^;
    Last edited by Ganon11; Oct 20 '07, 05:26 PM. Reason: Please use the [CODE] tags provided.
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    When you make the pair to insert, it may be treating "as" as a character array, not a string? That's the only thing I can think of.

    Comment

    • Studlyami
      Recognized Expert Contributor
      • Sep 2007
      • 464

      #3
      In your for loop why do you have for(start ; . . . ) as your first parameter. You already initialized it so you don't need anything in that first field.

      Comment

      Working...