delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/22/07:54:09

Message-ID: <003e01bde620$4b080280$866195cc@uic>
From: "Andrew Deren" <aderen AT interaccess DOT com>
To: "BDozer" <parsec AT nat DOT bg>, <djgpp AT delorie DOT com>
Subject: Re: OO question
Date: Tue, 22 Sep 1998 06:58:19 -0500

>Is this possible?
>for example here's a class:
>
>////////////
>class CLS
>{
>public:
>int x,y;
>.....
>void OnMouseClick(void);
>};
>////////////
>
>Can I assign other function to a method? Something like:
>
>////////////
>void MyFunc()
>{
>.....
>}
>
>CLS object;
>object.OnMouseClick = MyFunc(); (?)
>////////////
>

No you can't. But you can have a pointer to a function that is called inside
OnMouseClick
ex.
class Object {
public:
    int x, y;
    ...
    void OnMouseClick(void) { &click_callback; }
    void (*click_callback)(void);
};

void MyFunc()
{
    ...
}

Object object;
object.click_callback = MyFunc();

>
>
>
>


- Raw text -


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