hashMap in Unix - Unix

This is a discussion on hashMap in Unix - Unix ; Hi, team , Can any boby please tel me whether the code written below is work? Problem Statement: C++ Program to insert elements into a hashmap(say A). create new hashmap (say B). Copy the contents of A to B, Clear ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: hashMap in Unix

  1. hashMap in Unix

    Hi, team ,
    Can any boby please tel me whether the code written below is work?

    Problem Statement:

    C++ Program to insert elements into a hashmap(say A). create new
    hashmap (say B). Copy the contents of A to B, Clear the contents of
    hashmap A. then print the contents of hashMap B.




    #include
    #include

    #define HASH __gnu_cxx
    using namespace std;

    HASH::hash_map marks1;
    HASH::hash_map marks2;

    int main(void)
    {

    marks1["krisha"] = 65;
    marks1["archana"] = 35;
    marks1["shilpa"] = 25;
    marks1["ramya"] = 25;
    marks1["dhana"] = 25;
    marks1["poornima"] = 25;

    HASH::hash_map ::iterator itr;
    itr = marks1.begin();
    while(itr!=marks1.end())
    {
    std::cout<<"Key : "<first;
    std::cout<<" Value : "<second< itr++;
    }
    marks2=marks1;
    marks1.clear();


    HASH::hash_map ::iterator itr;
    itr = marks2.begin();
    while(itr!=marks2.end())
    {
    std::cout<<"Key : "<first;
    std::cout<<" Value : "<second< itr++;
    }
    return 0;

    }



  2. Re: hashMap in Unix

    On May 26, 8:03 am, navS wrote:
    > Hi, team ,
    > Can any boby please tel me whether the code written below is work?
    >
    > Problem Statement:
    >
    > C++ Program to insert elements into a hashmap(say A). create new
    > hashmap (say B). Copy the contents of A to B, Clear the contents of
    > hashmap A. then print the contents of hashMap B.
    >
    > #include
    > #include
    >
    > #define HASH __gnu_cxx
    > using namespace std;
    >
    > HASH::hash_map marks1;
    > HASH::hash_map marks2;
    >
    > int main(void)
    > {
    >
    > marks1["krisha"] = 65;
    > marks1["archana"] = 35;
    > marks1["shilpa"] = 25;
    > marks1["ramya"] = 25;
    > marks1["dhana"] = 25;
    > marks1["poornima"] = 25;
    >
    > HASH::hash_map ::iterator itr;
    > itr = marks1.begin();
    > while(itr!=marks1.end())
    > {
    > std::cout<<"Key : "<first;
    > std::cout<<" Value : "<second< > itr++;}
    >
    > marks2=marks1;
    > marks1.clear();
    >
    > HASH::hash_map ::iterator itr;
    > itr = marks2.begin();
    > while(itr!=marks2.end())
    > {
    > std::cout<<"Key : "<first;
    > std::cout<<" Value : "<second< > itr++;}
    >
    > return 0;
    >
    > }


    you'd have better luck asking on c.l.c++ / c.l.c++.moderated.
    Regarding the previous code, remove the second statement declaring itr
    as an iterator (double declaration).

    -- paulo

+ Reply to Thread