Code from the Derived class
Code:
void Book::print(ostream & out)const{
out << "BOOK: " << author << " " << '\"' << title << '\"' << " " << callNumber << endl;
} // This is a virtual function
ostream & operator<<(ostream & out, const Book & book){
book.print(out);
return out;
} // This is a friend function
The code that calls it looks like this
Code:
Book * book;
Recording * recording;
Holding * Holdings[5];
.
.
getting variable data
.
.
book = new Book(author, title, callNumber);
Holdings[i] = book; // Holdings is an ABC
cout << Holdings[i] << endl;
// cout << book << endl; (they both have the same result)