🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1280

Re: Pure virtual destructors!

#1280
From: Marc Girod
Date: Wed, 16 Dec 1992 09:05
74 lines
2826 bytes
Hi!

Abstract: To me everything was fine, but the fact that the programme
          was linked?!

Detailed:

>>>>> On Mon, 14 Dec 1992 18:39:29 GMT, tlukka@vinkku.hut.fi said:

tlukka> Pure virtual destructors dump core on HP-PA1.1 HP-UX 8.07
tlukka> Running the sample code won't succeed.

And this is ok. There was a bug in the former version of g++, making
this work!
Declaring a virtual member function pure is only a declaration, not a
definition.
It does not prevent you from defining it in addition (which was
forbidden by g++ v 2.3.1!).

In the case of a destructor, you actually must do it, because the
destructor for the base class WILL be called by the destructor for the
derived one!

tlukka> Compiles ok, though.

But to me, it shouldn't link! There is a missing definition for
B::~B(), once you explicitly declared it, no?

In any case, your keyword 'virtual' in ~B() declaration is redundant.

tlukka> ------ clip clip ---- sample code


tlukka> class A
tlukka> {
tlukka> 	int a;
tlukka> public:	
tlukka> 	A() {}
tlukka> 	virtual ~A()=0;
tlukka> };

tlukka> class B:public A
tlukka> {
tlukka> 	int b;
tlukka> public:
tlukka> 	B() {}
tlukka> 	virtual ~B()
tlukka> 	{
tlukka> 	}
tlukka> };


tlukka> int main()
tlukka> {
tlukka> 	B a;
tlukka> }

tlukka> ---------------------

Best Regards!

+-----------------------------------------------------------------------------+
| Marc Girod - Nokia Telecommunications       Phone: +358-0-511 7703          |
| TL4E - P.O. Box 12                            Fax: +358-0-511 7432          |
| SF-02611 Espoo 61 - Finland              Internet: marc.girod@ntc.nokia.com |
|    X.400: C=FI, A=Elisa, P=Nokia Telecom, UNIT=TRS, SUR=Girod, GIV=Marc     |
+-----------------------------------------------------------------------------+
--
+-----------------------------------------------------------------------------+
| Marc Girod - Nokia Telecommunications       Phone: +358-0-511 7703          |
| TL4E - P.O. Box 12                            Fax: +358-0-511 7432          |
| SF-02611 Espoo 61 - Finland              Internet: marc.girod@ntc.nokia.com |
|    X.400: C=FI, A=Elisa, P=Nokia Telecom, UNIT=TRS, SUR=Girod, GIV=Marc     |
+-----------------------------------------------------------------------------+
Technical Details
Message-ID: <GIROD.92Dec16110516@node_262d6.tele.nokia.fi>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tele.nokia.fi!girod
References: girod@tele.nokia.fi (Marc Girod)

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tele.nokia.fi!girod
From: girod@tele.nokia.fi (Marc Girod)
Subject: Re: Pure virtual destructors!
Message-ID: <GIROD.92Dec16110516@node_262d6.tele.nokia.fi>
Sender: gnulists@ai.mit.edu
Reply-To: marc.girod@ntc.nokia.com
Organization: kpd
References: girod@tele.nokia.fi (Marc Girod)
Distribution: gnu
Date: Wed, 16 Dec 1992 09:05:16 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 75