How to produce output using show function
I am trying to use sho to show the output of another function.The first function was used to do sorting, and returned a List.
now I want to make a function that uses show() to display the output.This is how I had tried it only to get an error.
Its to diplay the results of two the two sorted lists which used this function.
//Function that does the compare!
map<int, Bid*> Auctioneer::compareBidList(map<int, Bid*>& one, map<int, Bid*>&
two) // pass references &
{
map<int, Bid*> Sorted;
map<int, Bid*>::iterator iterOne;
for(iterOne = one.begin(); iterOne != one.end(); ++iterOne)
{
if(iterOne->second->bidType == 'A') // select all type A from one
{
map<int, Bid*>::iterator iterTwo;
for(iterTwo = two.begin(); iterTwo != two.end(); ++iterTwo)
{
if(iterTwo->second->bidType == 'B') // select all
type B from two
{
if(iterOne->second->price < iterTwo->second-
>price) // select on price between type A and type B
{
Sorted.insert(*iterOne);
Sorted.insert(*iterTwo);
}
}
}
}
}
return Sorted;
}
void show(map<int, Bid*>& one, map<int, Bid*>& two) {
map<int, Bid*>::iterator iterOne;
map<int, Bid*>::iterator iterTwo;
cout << "-----------------The sorted List-------------------------";
for(iterOne=Sorted.begin(); iterOne!= Sorted.end(); iterOne++){
cout << iterOne->seco开发者_如何学运维nd->toString() << endl<<"\n";}
for(iterTwo=Sorted.begin(); iterTwo!= Sorted.end(); iterTwo){
cout << iterTwo->second->toString() << endl<<"\n";}
}
void show(const char *msg, map<int, Bid*>& Sorted) {
cout << msg << endl;
show(Sorted);
}
void compare(map<int, Bid*>& sellers, map<int, Bid*>& buyers) {
compare(sellers.begin(), sellers.end(),
buyers.begin(),buyers.end(),compareBidList); }
//my call in the main after declaration was as follows
map<int, Bid*> buyers, sellers;
auctioneer.compare(sellers,buyers);
show("Bids after sorting:", sellers);
show(buyers);
Remove the extra parenthesis, and call show twice (your declaration only takes one map object):
show("Bids after sorting:", sellers);
show(buyers);
精彩评论