Can users enumerate variables to functions?
If it is possible then can anyone provide me some examples?
Can users enumerate variables to functions?
If it is possible then can anyone provide me some examples?
Here would be the returning data type and variable with its function, for example:
enum File_Functions { file_read, file_write };
int file_read();
int file_write();
Can those returning variables with their designated built-in functions work?
Maybe you need a function pointer, an array of function pointers, or a structure that contains function pointers, depending on other details about your needs.
Hello,
no, it's not possible in the way you want to do. enum doesn't collect function names.
Read this: enum
You can use the enum for named identifiers so that your code gets more readable. And use an if-statement to call the corresponding function.
For example:
enum eFileFunctions { FILE_READ = 1, FILE_WRITE };
switch (ifunc)
{
case FILE_READ: iRet = file_read(); break;
case FILE_WRITE: iRet = file_write(); break;
default: cout << "unknown function" << endl;
}
Regards, Guido
8 people are following this question.