You could easily fix this by not making operator<< a friend at all. operator<< works as well as a non-member non-friend function which calls get_num() and get_den(), so that is one answer you could...