Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #22630

Re: Map C++ feature to C

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!nuzba.szn.dk!pnx.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c
Subject Re: Map C++ feature to C
Date Mon, 25 Jun 2012 10:15:08 +1200
Lines 26
Message-ID <a4phrcFaukU2@mid.individual.net> (permalink)
References <js6ip6$qb1$1@speranza.aioe.org> <a4o4ojFe9mU2@mid.individual.net> <js7n1a$buh$1@news.albasani.net>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net 3b6LkC/to7Nw2E7T7jDMYggtsTUf/DgY/Cx4zglZLeH29EpYA3BrR5jHF/QGO9rjhl
Cancel-Lock sha1:/R7xLvq4dmSKAdvPUHVKO3KVbow=
User-Agent Mozilla/5.0 (X11; SunOS i86pc; rv:12.0) Gecko/20120423 Thunderbird/12.0
In-Reply-To <js7n1a$buh$1@news.albasani.net>
Xref csiph.com comp.lang.c:22630

Show key headers only | View raw


On 06/25/12 06:39 AM, BGB wrote:
> On 6/24/2012 4:25 AM, Ian Collins wrote:
>> On 06/24/12 08:23 PM, zgene wrote:
>>> Dear friends
>>
>> Why is the question completely different form the subject?
>>
>>> Is there a way to embulate C++'s virtual destructors in pure C. IE just
>>> using function pointers.
>>
>> No, because there isn't a way to fully emulate destructors.
>>
>
> strictly speaking, yes.
>
> but if one allows for the case where the destructor is called via the
> object being manually destroyed/"deleted", then it becomes a little
> easier: just have it as a method/function-pointer which is called prior
> to freeing the memory.

A "little" easier is the appropriate term.  The OP asked for virtual 
destructor functionality, which requires some form of virtual dispatch 
mechanism.  Doable, but ugly.

-- 
Ian Collins

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Map C++ feature to C zgene <nospam@nospam.com> - 2012-06-24 08:23 +0000
  Re: Map C++ feature to C Ian Collins <ian-news@hotmail.com> - 2012-06-24 21:25 +1200
    Re: Map C++ feature to C BGB <cr88192@hotmail.com> - 2012-06-24 13:39 -0500
      Re: Map C++ feature to C Ian Collins <ian-news@hotmail.com> - 2012-06-25 10:15 +1200
        Re: Map C++ feature to C BGB <cr88192@hotmail.com> - 2012-06-25 11:32 -0500
    Re: Map C++ feature to C zgene <nospam@nospam.com> - 2012-06-24 21:33 +0000
      Re: Map C++ feature to C Ian Collins <ian-news@hotmail.com> - 2012-06-25 10:12 +1200
        Re: Map C++ feature to C William Ahern <william@wilbur.25thandClement.com> - 2012-06-24 18:49 -0700
        Re: Map C++ feature to C nroberts <roberts.noah@gmail.com> - 2012-07-23 10:25 -0700
          Re: Map C++ feature to C Andrew Cooper <amc96@cam.ac.uk> - 2012-07-24 01:34 +0100
            Re: Map C++ feature to C Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-07-24 15:58 +0000
  Re: Map C++ feature to C "christian.bau" <christian.bau@cbau.wanadoo.co.uk> - 2012-06-24 11:36 -0700
    Re: Map C++ feature to C Leo Havmøller <rtxleh@nospam.nospam> - 2012-06-25 05:43 +0200
      Re: Map C++ feature to C Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-06-25 10:34 +0000
        Re: Map C++ feature to C BGB <cr88192@hotmail.com> - 2012-06-25 11:36 -0500
  Re: Map C++ feature to C Paul N <gw7rib@aol.com> - 2012-06-24 12:19 -0700
    Re: Map C++ feature to C 88888 Dihedral <dihedral88888@googlemail.com> - 2012-06-24 19:49 -0700
  Re: Map C++ feature to C aftnix <aftnix@gmail.com> - 2012-07-26 13:36 -0700

csiph-web