Function pointer in stucts

Posted By: TWO

Function pointer in stucts - 07/07/07 23:39

typedef struct
{
void LeftClick();
} AwakeGUI_WindowElement;

function odd();
{
}

AwakeGUI_WindowElement Element;

Element.LeftClick = odd;
Element.LeftClick(); // ERROR

?
Posted By: TWO

Re: Function pointer in stucts - 07/09/07 11:21

Waaaaaaaaaaaaah!
Posted By: jcl

Re: Function pointer in stucts - 07/09/07 11:31

This is no valid C code. In C you can store function pointers in struct elements, but you can't call a struct element.
Posted By: TWO

Re: Function pointer in stucts - 07/09/07 12:44

I know I can't treat a void like a function, I posted to get to know how I can archive something similar.
Posted By: jcl

Re: Function pointer in stucts - 07/09/07 15:20

Just as you did, only without the struct.

void LeftClick();
LeftClick = odd;
LeftClick();
© 2024 lite-C Forums