J'essaye d'utiliser sho pour montrer la sortie d'une autre fonction. La première fonction a été utilisée pour faire le tri, et a renvoyé une liste.Comment produire une sortie en utilisant la fonction show
maintenant je veux faire une fonction qui utilise show() pour afficher la sortie. C'est ainsi que je l'ai essayé seulement pour obtenir une erreur.
Son pour afficher les résultats de deux les deux listes triées qui ont utilisé cette fonction.
//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);
On va avoir besoin d'un peu plus que cela. Que devrait-on "faire"? Imprimer sur une console, afficher une fenêtre, écrire dans un navigateur, lancer un avion de skywriting? –
Lorsque vous obtenez une erreur, vous devez nous dire quelle est l'erreur. –