www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/31/15:20:59

From: John Clonts <johncc AT my-deja DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Function pointers in C++
Date: Tue, 31 Aug 1999 13:15:57 GMT
Organization: Deja.com - Share what you know. Learn what you don't.
Lines: 60
Message-ID: <7qgki1$ijk$1@nnrp1.deja.com>
References: <37CBBE53 DOT EECABDD5 AT club-internet DOT fr>
NNTP-Posting-Host: 204.254.32.135
X-Article-Creation-Date: Tue Aug 31 13:15:57 1999 GMT
X-Http-User-Agent: Mozilla/3.01Gold (Win95; I)
X-Http-Proxy: 1.0 x35.deja.com:80 (Squid/1.1.22) for client 204.254.32.135
X-MyDeja-Info: XMYDJUIDjohncc
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

In article <37CBBE53 DOT EECABDD5 AT club-internet DOT fr>,
  flupke <schawat AT club-internet DOT fr> wrote:
> Hello.
>
> I don't know if i'm doing a "c++ misunderstanding" or if it's a djgpp
> problem, but here is my problem anyway.
> When i execute this piece of code:
>
> ***********************
> #include <iostream.h>
>
> class glou
> {
> public:
>     int c;
>
>     glou()
>     {
>         c = 0;
>         a = &b;
>     }
>
>     void (*a)();

   void (glou::*a)();

>
>     void b()
>     {
>         c++;
>     }
> };
>
> int main()
> {
>     glou blou;
>
>     cout << blou.c << endl;
>
>     blou.a();

      (blou.*(blou.a))();

>     cout << blou.c << endl;
>
>     blou.b();
>     cout << blou.c << endl;
>
>     return 0;
> }
>

As usual with function pointers, typdefs can help here.

Cheers,
John


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

- Raw text -


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