Hey Thomas,

> My initial thought was to use function pointers and a list.  If the
> function is defined outside the class, I can add it to the list.  f1
> in the example.  If the function is declared in the class, I get a
> compile error, f2 in the example.  I have tried qualifying f2, etc.
> No luck.
Showing the compiler error message would have been helpful. I suspect
you'll have seen some type error, since you didn't make f2 a static
function.

> class MyList {
>  private:
>   list<bool (*)(void)> list1;
>   bool f2(void);

Here, f2 is a normal (non-static) member function, meaning it should be
called _on_ an object (under water it actually has an extra "this"
argument).

I think declaring f2 as a static member function would fix you problem.
If you need f2 to remain a normal function, you'll have to create a
list that stores both the member function to call, as well as the object
to call it on.  Google for "member function pointer" for more info.

Gr.

Matthijs

Attachment: signature.asc
Description: Digital signature

_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to