Original Post
Hello, I have encountered this problem with function pointers while implementing a component for my game engine, but I post it in this section of the forums since it is rather a general programming problem. I want to implement a Quake-like console along with a scripting engine. I'd like to do this mainly to make testing and debugging easier. There are many problems to solve like how to draw the console on the screen, how to receive the input, how to parse commands etc. However, these are not my concerns at the moment as I have implemented similar things many times before. My problem is that I want to implement a generic function pointer container to store the function pointers that correspond to console commands, i.e. the pointer to the function to execute when a particular command (and possibly zero or more parameters) are sent to the command executer from the console. The real problem here is that I don't want to restrict the signature of these functions to some predefined signature and the other problem is that I want to be able to use member functions with these systems since the functions I'll be calling will mostly be member functions. I have read several articles about using member function pointers conveniently (and fast) but I'm not sure how I can store functions with different signatures in the same container. One other important thing is that I have a working system now and I'd like to change other classes in my game engine as little as possible (preferably no changes at all), e.g. changes like defining a new base class and having other classes subclass this base class etc. I'd like to listen to your suggestions/opinions about the issue I mentioned above. If my problem is not clear enough, which is likely, please let me know and I'll try to explain it more clearly and possibly along with some code and usage examples. Thanks for your time,