🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Virtual functions and destructors

#2498
From: Herb Sutter
Date: Fri, 10 Nov 1995 19:30
27 lines
1862 bytes
In article <199511100139.UAA11974@starling.WPI.EDU>,
   Chris Parker <parker@owl.WPI.EDU> wrote:
>	The thing that doesn't work for me is that the pointer type is 
>different, but it still has the same pointer value.  At the low-level, you
>are freeing the same block of memory either way.  In order to 
>call a destructor, the system needs to convert the pointer to a class type
>instance anyway.

I don't follow.  To begin with, you certainly often do have different pointer 
values for the same object depending on which base pointer(s) you use to 
access it.  Simple example: Base classes B1 and B2, derived class D from both 
bases, and any D object will have a different pointer value when viewed 
through a B1* and a B2*; a B1* points to the "B1 part" of the derived object 
and a B2* points to the "B2 part" of the derived object.

If you fix that first sentence I think you'll see how to fix the rest too.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Herb Sutter                 2228 Urwin, Ste 102         voice (416) 618-0184
Connected Object Solutions  Oakville ON Canada L6L 2T2    fax (905) 847-6019

---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <199511101834.NAA20540@gold.interlog.com>
Path: arc1-ca.pugleaf.net!128.32.155.1!matt
References: <199511100139.UAA11974@starling.WPI.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!128.32.155.1!matt
From: herbs@interlog.com (Herb Sutter)
Newsgroups: comp.std.c++
Subject: Re: Virtual functions and destructors
Date: 10 Nov 1995 19:30:44 GMT
Organization: Connected Object Solutions (div of Daystar Software Systems Design Inc.)
Approved: matt@physics2.Berkeley.EDU (Matt Austern)
Message-ID: <199511101834.NAA20540@gold.interlog.com>
References: <199511100139.UAA11974@starling.WPI.EDU>
NNTP-Posting-Host: physics2.berkeley.edu