class BidderCollection {
⋮
// Print the collection
void print (std::ostream& out) const;
// Comparison operators
bool operator== (const BidderCollection&) const;
bool operator< (const BidderCollection&) const;
};All of these require us to walk the list, one node at a time, but we've already seen how to do that.
// Print the collection
void BidderCollection::print (std::ostream& out) const
{
out << size << "{";
Position current = list.first;
while (current != NULL)
{
out << " ";
current->data.print (out);
out << "\n";
current = current->next;
}
out << "}";
}
or
// Print the collection
void BidderCollection::print (std::ostream& out) const
{
out << size << "{";
for (Position current = list.first;
current != NULL; current = current->next)
{
out << " ";
current->data.print (out);
out << "\n";
}
out << "}";
}