[comp.lang.c++] Why is << in the class ostream not virtual?

amb@Apple.COM (A. Michael Burbidge) (10/12/90)

I am trying to create a class that is derived from ostream. The new class has
only one additional behavior. It will optionally ignore output requests. Two
additional methods called On and Off control whether output is ignored.

Everything was going great until I discovered that the << operators in ostream
are not virtual. Why? Any other ideas on how to accomplish the task at hand.

Mike Burbidge
amb@apple.com

roger@procase.UUCP (Roger H. Scott) (10/16/90)

In article <45575@apple.Apple.COM> amb@Apple.COM (A. Michael Burbidge) writes:
>... I discovered that the << operators in ostream are not virtual. Why?

Two reasons: first, because the creators of C++ made, IMHO, the wrong decision
about the default binding of member functions - i.e., non-virtual is the
default so you have to say *more* to get the (again, IMHO) normal virtual
behavior; second, because the class designers had the gall to presume that
you wouldn't want/need to redefine the implementation of this operation.

It is probably too late to do anything about the first problem, but the
second problem *is* under our (programmers') control.  Do the right thing -
make them virtual!