🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac.programmer.codewarrior
Article #7

Re: C++ hierarchy problem

#7
From: Telesis North
Date: Mon, 07 Aug 1995 17:06
19 lines
1202 bytes
In article <3vqr6h$8nj@imag.imag.fr>,
Gilles Serasset  <Gilles.Serasset@imag.fr> wrote:
>I face a problem related to C++ classes. And I would like to know how to
>get rid of it.
>
>void A2::DoThis(void) { ((B2 *)(this->bb))->DoThat(); }
>
>B3 inherits from B2 and redefines DoThat().
>A2 is not modified (but its bb slot contains a B3 instance).

If I understand your system correctly, then making B2::DoThat() virtual
ought to give you what you want. (Might as well declare A2::DoThis()
virtual as well, for symmetry if nothing else.)

cheers,

Roger Pantos                 Telesis North, Inc.           telesisnorth
Mac Software Guy             telesis@ecf.toronto.edu       (AppleLink)
I've got a Mac instead of a DOS box because I need a tool, not a hobby.
Technical Details
Message-ID: <DCyA6G.Mrz@ecf.toronto.edu>
Path: arc1-ca.pugleaf.net!cannon.ecf!telesis
References: <3vqr6h$8nj@imag.imag.fr>

Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.mac.programmer.codewarrior,comp.sys.mac.oop.misc,comp.lang.c++
Path: arc1-ca.pugleaf.net!cannon.ecf!telesis
From: telesis@ecf.toronto.edu (Telesis North)
Subject: Re: C++ hierarchy problem
X-Nntp-Posting-Host: spark24.ecf
Message-ID: <DCyA6G.Mrz@ecf.toronto.edu>
Sender: news@ecf.toronto.edu (News Administrator)
Organization: sparodic
References: <3vqr6h$8nj@imag.imag.fr>
Date: Mon, 7 Aug 1995 17:06:16 GMT