www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/20/03:02:17

From: horst DOT kraemer AT gmx DOT de (Horst Kraemer)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DJGPP doesn't understand pointer to member function
Date: Sat, 20 May 2000 04:55:05 GMT
Lines: 49
Message-ID: <3925959b.142758406@news.cis.dfn.de>
References: <8g35td$2mt$15$1 AT news DOT t-online DOT com>
NNTP-Posting-Host: pd4b89034.dip.t-dialin.net (212.184.144.52)
X-Trace: fu-berlin.de 958798489 703000 212.184.144.52 (16 [27606])
X-Newsreader: Forte Free Agent 1.11/32.235
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Fri, 19 May 2000 12:42:47 +0200, "Ortwin Wagner"
<owsadlerhorst AT t-online DOT de> wrote:

> If I call a member function by means of a pointer like
> ...

It's not a problem of _calling_, it's a problem of assigning...

> class Mammal...
> class Horse : public Mammal...
> ...
> Mammal * ptr=0;
> ptr= new Horse;
> void (Mammal::*pFunc)() const=0;
> pFunc=Mammal::Speak;
> (ptr->*pFunc)();
> ...

I hope you didn't try to call a function through a null pointer...

> DJGPP returns a strange error message: "Assuming & on Mammal::Speak". As far
> as I know the code is completely correct and so it looks like a lack of
> intelligence of the compiler, doesn't it?

According to my experience it's usually the programmer who is lacking
intelligence.

The correct syntax is

	pFunc = &Mammal::Speak;

and that's what the compiler tried to tell you. Moreover the message
means that the compiler _did_ replace you incorrect assignment

	pFunc = Mammal::Speak;

by the correct version

	pFunc = &Mammal::Speak;

(look up a dictionnary what "assume" means)

and compiled what you expected. This is definitely a sign of
intelligence and not of lack of intelligence, isn't it ?


Regards
Horst

- Raw text -


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