There’s a better answer. Remove the overloaded operator<< functions for Apple and Banana. You don’t need them.
Without them, Fruit::operator<< will be called, and that function already has everything it needs to print the Fruit’s name and color.
There’s a better answer. Remove the overloaded operator<< functions for Apple and Banana. You don’t need them.
Without them, Fruit::operator<< will be called, and that function already has everything it needs to print the Fruit’s name and color.