Function pointers/references ( [ANN] NTL "Nonstandard Template Library")

Function pointers/references ( [ANN] NTL "Nonstandard Template Library")

Post by Jean-Marc » Tue, 08 Jul 2003 18:46:15


Francis Glassborow < XXXX@XXXXX.COM > writes:

> In message < XXXX@XXXXX.COM >,
> XXXX@XXXXX.COM writes
> > - Considering the three "standard" uses, C++ is rather ambiguous
> > between values and functions -- a function is really the address of
> > a function, and a pointer to a function can be used to call a
> > function. On the other hand, you have to know what is a type and
> > what not in order to parse the code. This suggests that if you
> > separate into two groups, types should in a group by themselves.
>
> Yet function names behave very like objects and I wonder why we get so
> hooked on the term function pointer:
>
> typedef void(plot_function) (int x, int y, hue shade);
>
> draw_line(point from, point to, plot_function &);
>
> works quite happily and there are no pointers in view.

Usually I use function pointers only when compatibility with C is
important, so using function references is not an option.

If compatibility with C is not important, I use a virtual member
function of an interface class.

Yours,

--
Jean-Marc

[ See http://www.yqcomputer.com/ ]
[ comp.lang.c++.moderated. First time posters: Do this! ]