accessing values in a Map container, whose values were passed on as a stream

Posted by wilson88 on Stack Overflow See other posts from Stack Overflow or by wilson88
Published on 2010-05-16T03:37:00Z Indexed on 2010/05/16 3:40 UTC
Read the original article Hit count: 341

Filed under:

I am trying to get access to the object values of the objects that were sent as a stream from one class to ano ther.Aparently I can view the objects via their keys but am not so sure how to get to the values.ie Bid- values trdId,qty, price. If possible you can demostrate how I can make comparison for the prices in the containers buyers and sellers for the prices. code is as below:

void Auctioneer::printTable(map bidtable)

          { map<int, Bid*>::const_iterator iter;

            cout << "\t\tBidID | TradID | Type  | Qty  |  Price  \n\n";  
            for(iter=bidtable.begin(); iter != bidtable.end(); iter++)//{     
            cout << iter->second->toString() << endl<<"\n";

//-------------------------------------------------------------------------                    
             // Creating another map for the sellers.
             cout<<"These are the Sellers bids\n\n";
             map<int, Bid*> sellers(bidtable);
             sellers.erase(10);sellers.erase(11);sellers.erase(12);sellers.erase(13);sellers.erase(14);
             sellers.erase(15);sellers.erase(16); sellers.erase(17);sellers.erase(18);sellers.erase(19);
             for(iter=sellers.begin(); iter != sellers.end(); iter++)
             cout << iter->second->toString() << endl<<"\n";

//--------------------------------------------------------------------------           
             // Creating another map for the sellers.
             cout<<"These are the Buyers bids\n\n";
             map<int, Bid*> buyers(bidtable);
             buyers.erase(0);buyers.erase(1);buyers.erase(2);buyers.erase(3);buyers.erase(4);buyers.erase(5);
             buyers.erase(6);buyers.erase(7); buyers.erase(8);buyers.erase(9);
             for(iter=buyers.begin(); iter != buyers.end(); iter++)

             //sellers.erase(10);
             cout << iter->second->toString() << endl<<"\n";

© Stack Overflow or respective owner

Related posts about c++