need input on a generalized command interpreter


i have a game (called zzt++) which consists of several (C++)classes. many of these classes contain a command loop where a character is read from the keyboard and a function is called in a switch(c){ case:... } statement.

i am trying to eliminate the need for such a command loop in each class, by creating a generalized command interpreter. what i have done so far is create a class which takes pointers to functions in an array as well as user actions in another array. the command interpreter then matches keypresses with the user actions in the second array and calls the functions in the first array.

there are two problems: i can only pass pointers to static member functions in C++ (which can only access static data members). i can not pass parameters in the way i would like.

what should i do? are there other (better) techniques?

any input you can give me will be appreciated.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!