delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/04/30/08:28:57

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Pointers to methods
Date: 30 Apr 2001 11:22:17 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 21
Message-ID: <9cjht9$hq5$1@nets3.rz.RWTH-Aachen.DE>
References: <9cfogs$9v4$1 AT news DOT adamastor DOT ac DOT za>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 988629737 18245 137.226.32.75 (30 Apr 2001 11:22:17 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 30 Apr 2001 11:22:17 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hentie Louw <13080555 AT narga DOT sun DOT ac DOT za> wrote:

> This requires me to use pointers to procedures. It would do wonders for my
> code if I could have pointers to methods in my classes, but I can't seem to
> do it. Is it possible? 

Yes. But without wrapper functions, as you currently already do it,
you have to use a special C++ syntax to reinterpret a method pointer
as a function pointer, or you have to restrict yourself to static
methods. The difference is the hidden 'this' argument --- static
methods don't have it, and thus behave more like classical C
functions.

Generally spoken, function pointers are rather alien to an OO type
language like C++. You would usually use subclassing, instead.



-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019