我正在尝试使用sho来显示另一个函数的输出。第一个函数用于进行排序,并返回一个List。
现在我想创建一个使用show()来显示输出的函数。这就是我尝试它只是为了得到一个错误。
它用于显示两个使用此函数的两个排序列表的结果。
//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->second->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);
答案 0 :(得分:0)
删除额外的括号,并调用show两次(您的声明只接受一个地图对象):
show("Bids after sorting:", sellers);
show(buyers);