🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #911

Re: ~virtual (followup to ~const proposal 1.6)

#911
From: Bjarne Stroustrup
Date: Sun, 03 Mar 1991 13:43
28 lines
1237 bytes

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()
Technical Details
Message-ID: <20012@alice.att.com>
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!mit-eddie!andante!alice!bs
References: <NGO.91Mar2014617@tammy.harvard.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <NGO.91Mar2014617@tammy.harvard.edu>
Distribution: comp
Organization: AT&T Bell Laboratories, Murray Hill NJ
Lines: 28