Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!mit-eddie!andante!alice!bs From: bs@alice.att.com (Bjarne Stroustrup) Newsgroups: comp.std.c++ Subject: Re: ~virtual (followup to ~const proposal 1.6) Summary: warnings can be useful Message-ID: <20012@alice.att.com> Date: 3 Mar 91 13:43:03 GMT References: Distribution: comp Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 28 ngo@tammy.harvard.edu (Tom Ngo @ Harvard Chemistry Department) writes > The opposite thing has also happened to me: in a derived class I have > meant for a function to be virtual, but because of a minor difference > in declaration the method in the derived class has created a new vtbl > entry instead of filling in one declared in its base class. For > example: > > class Base { > virtual double foo(); > }; > class Derived { > virtual double foo() const; > }; > > Could once think of some protection against this sort of error? I think you meant class Derived : Base { virtual double foo() const; }; In that case cfront 2.0 warns: "", line 5: warning: Derived::foo() hides virtual Base::foo()