Thread overview
Function Pointers
May 30, 2005
Trevor Parscal
May 30, 2005
Tom S
May 30, 2005
Trevor Parscal
May 30, 2005
Tom S
May 31, 2005
Stewart Gordon
May 30, 2005
Lets say I have a class..

class PIXEL
{
private:
int x, y;

public:
bit function() CallBack;
this()
{
this.CallBack = null;
}
void Set(int _x, int _y)
{
this.x = _x;
this.y = _y;
if(&this.CallBack != null)
{
this.CallBack();
}
}
};

Which I intend on (if connected) sending a notification to whatever I attach to the callback that the value was changed.

And than I have another class, which has the actual function I want to set the callback up to call...

class FOO
{
private:
update()
{
// update code
}
public:
PIXEL Pixel;
this()
{
this.Pixel = new PIXEL();
this.Pixel.CallBack = &this.update;
}
};

Why am I screwed? Cause the compiler says i have to make update() a static
function, however, I want update() to use the "this" operator...

Any way to work around this?

Any help is greatly appriciated.

Thanks,
Trevor Parscal
www.trevorparscal.com
trevorparscal@hotmail.com
May 30, 2005
Trevor Parscal wrote:
> Why am I screwed?

change this:
> bit function() CallBack;

to:
bit delegate() CallBack

and everything shall be fine


-- 
Tomasz Stachowiak  /+ a.k.a. h3r3tic +/
May 30, 2005
In article <d7f31i$21qi$1@digitaldaemon.com>, Tom S says...
>
>Trevor Parscal wrote:
>> Why am I screwed?
>
>change this:
>> bit function() CallBack;
>
>to:
>bit delegate() CallBack
>
>and everything shall be fine
>
>
>-- 
>Tomasz Stachowiak  /+ a.k.a. h3r3tic +/


Thank YOU!!!! I feel stupid, but mostly thankful that you could answer my question.

WHY is it the later at night it gets the less capable we are at solving simple problems?

Thanks Again!
Trevor Parscal
www.trevorparscal.com
trevorparscal@hotmail.com
May 30, 2005
Trevor Parscal wrote:
> Thank YOU!!!! I feel stupid, but mostly thankful that you could answer my
> question.
> 
> WHY is it the later at night it gets the less capable we are at solving simple
> problems?

It's just a matter of skillful dosing of caffeine <g>


-- 
Tomasz Stachowiak  /+ a.k.a. h3r3tic +/
May 31, 2005
Trevor Parscal wrote:
> Lets say I have a class..
> 
> class PIXEL
> {
> private:
> int x, y;
> 
> public:
> bit function() CallBack;
> this()
> {
> this.CallBack = null;
> }
> void Set(int _x, int _y)
> {
> this.x = _x;
> this.y = _y;
> if(&this.CallBack != null)
<snip>

Wouldn't this test the address at which the pointer is situated, rather than testing the pointer itself?

Stewart.

-- 
My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.