🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Legal C++ code?

#3468
From: Fergus Henderson
Date: Fri, 16 Feb 1996 04:39
28 lines
1581 bytes
tim@franck.Princeton.EDU (Tim Hollebeek) writes:

>Is the following legal C++ code?  g++ compiles it, but it doesn't link
>(undefined function Foo::foo()). 

No, the following code is not legal, because you don't have a definition
for the pure virtual function Foo::foo().  But if you add one, e.g.

	int Foo::foo() { return 42; }

then the code is quite legal.

>I'm suprised it compiles at all:

It has always been legal in C++ to provide a definition for pure
virtual functions, although the only way to invoke such a function is
by using an explicit qualification.

Yes, this suprised me too ;-)  I think it would have been simpler to
disallow definitions of pure virtual functions.

--
Fergus Henderson             	WWW: http://www.cs.mu.oz.au/~fjh
fjh@cs.mu.oz.au              	PGP: finger fjh@128.250.37.3
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  Moderation policy:
  http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
Technical Details
Message-ID: <4g11oe$b2d@mulga.cs.mu.OZ.AU>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <4fvtk3$16j@cnn.Princeton.EDU>

Show Full Headers
Complete Article Headers
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Message-ID: <4g11oe$b2d@mulga.cs.mu.OZ.AU>
X-Original-Date: 16 Feb 1996 04:38:38 GMT
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 16 Feb 96 04:39:50 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
Subject: Re: Legal C++ code?
Organization: Comp Sci, University of Melbourne
References: <4fvtk3$16j@cnn.Princeton.EDU>
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMSQKpOEDnX0m9pzZAQEjjgF/XRhQ70WrurXQyPGZuuAL5FHUVWy2lnUl
 hNy+CemtNXGLe1hytek0SOAVyD1pklJw
 =v+fV