Original Post
hi,
suppose i have a program (called zzt++) written in C++ which contains a number of classes, many of which contain a command loop: a loop reading characters from the keyboard and calling functions accordingly using a switch(c){ case: ... } statement.
i am trying to eliminate the use of a command loop in every class by creating a single class which does this work for all other classes requiring a command loop.
i do this by first filling an array with pointers to functions and then filling another array with the corresponding user actions required to call the functions. the generalized command interpreter then reads the keyboard, matches the user''s key presses and calls the appropriate function.
sounds cool, doesn''t it? and it works, except for these two things:
1. i can only pass pointers to static member functions in C++. static memeber functions can only use static data members.
2. it is not possible to pass parameters in this way.
who knows another (better) way of doing this?
any input will be appreciated.
WeP
http://www.planetzztpp.com