[comp.lang.c++] Pointers to functions as members

db@its63b.ed.ac.uk (D Berry) (05/16/88)

Is it possible to have a member of a class or struct which is a pointer
to a function?  I've tried the obvious syntax, but I couldn't get it
to work.

If not, why not?  I don't understand.   (where's the tea? :-)

If so, what is the correct syntax?


I'm trying to write a menu package which associates pointers to
functions with each entry in a menu.  This seems the obvious way
to do it.

The 'squares' program provided with InterViews as an example program
defines an enumerated type for each menu.  Each menu has associated with
it a unique subclass of the class MenuItem.  Clicking on an entry calls a
function which does a switch on the enumerated type.  This works OK, but it
seems cumbersome and difficult to update dynamically.  Am I missing something?
-- 
-------------------------------------------------------------------------------
 "England has become ... an intolerant, rascist, homophobic, narrow-minded
  authoritarian rat hole run by vicious suburban-minded materialistic
  philistines" -- Hanif Kureishi
-------------------------------------------------------------------------------
 Dave Berry.	db%lfcs.ed.ac.uk@nss.cs.ucl.ac.uk