There's really not much to either topic.
The one hard part about pointers to functions
is to remember to put parentesis around the
* and the function name.

void (*funcpoint)();
void func() { printf("Hello\n"); }
funcpoint = func; /* Notice no parenthesis! */
(*funcpoint)(); /* "Hello\n" is displayed */

Function pointers must point to static functions.
Any function which is standalone (not part of a
class; freely defined with global scope) is static.
(Others on the list verify this, please.)  Member
functions (C++) are only static if you give the
static keyword.  You cannot mix static with the
virtual keyword.  (Grrr...) 

void pointers (vastly different than the
case of above.  Above was a pointer to a function
with void parameters and void return type.  A
void pointer can point to *anything*, but you must
type cast it if it is on the right side of an equals sign.

void *pointertoanything;
char mychar;
int myint;
char *mycharptr;
int *myintptr;

pointertoanything = &mychar;
mycharptr = (char*)pointertoanything;
pointertoanything = &myint;
myintptr = (int*)pointertoanything;

I'm sorry if I confused you more than I helped.  :-(
I don't think I've ever found a book which gave
more than 1/2 - 1 page of info on either of these
topics.  Not that they're easy, just that there's not
much to them.

~Patrick

> ----------
> From:         [EMAIL PROTECTED]
> 
> 
> Hey all..is there a definitive book to learn how to use pointers to
> functions and void* variable types? I'd also like to tie it into
> reusability and OOP if at all possible (no I can't use C++ or any standard
> OO language)
> 
> Thanks,
> Chris
> 
> 

Reply via email to