hi,
I am designing a parser to read the input file for my code. In that, I use various commands and associate those commands with the relevant functions. Each time, i endup in adding a couple of lines like
if(strcmp(cmd,"clear")==0)
return clear();
else if(strcmp(cmd,"copy")==0)
return copy();
All the member functions in that class are of same name as the commands. So, i need to automate this process in order to avoid the above statements. In otherwords, i want some thing like below ( function pointers? )
for(int i=0;i<num_func;i++)
if(strcmp(cmd,func_name[i])==0)
return func[i]();
Please let me know.
Regards,
Shyam