S
shahehe
Hi
I have a list of strings in a file and I want to call different
functions according to each string I parsed from the file.
For example, if I read "LOAD" from the file, I should call void
read(void) . If I read "SAVE" from the file, I should call function
void save(string fileName).
I do not want to use switch here. Also, I know I may use map of
function pointers here.
typedef void (*Function_Ptr)(void );
typedef std::map<string, Function_Ptr> Processing_Map;
....
However, each function has different parameters, what's the best to
code the above case?
thanks
I have a list of strings in a file and I want to call different
functions according to each string I parsed from the file.
For example, if I read "LOAD" from the file, I should call void
read(void) . If I read "SAVE" from the file, I should call function
void save(string fileName).
I do not want to use switch here. Also, I know I may use map of
function pointers here.
typedef void (*Function_Ptr)(void );
typedef std::map<string, Function_Ptr> Processing_Map;
....
However, each function has different parameters, what's the best to
code the above case?
thanks