Original Post
🔒 Locked
Function array?
Advertisement
quote:
Original post by Anonymous Poster
const int MAX_FUNCTION= 300;
void (fnPointer*)(...);
fnPointer farray[MAX_FUNCTION];
switch(code) {
case SPRINTF:
farray[SPRINTF]("printing using func array\n");
break;
case OTHER:
farray[OTHER](std::ostream(os));
break;
case SOMETHING_OTHER:
farray[SOMETHING_OTHER](true);
break;
case ANOTHER_OTHER:
farray[ANOTHER_OTHER](std::complex(1, 0));
break;
case LAST_OTHER:
farray[LAST_OTHER](std::complex(1, 0), std::complex(9.0, 14));
break;
default:
farray[DEFAULT]("default called",false);
}
etc.
If I saw you do this I''d have to sack you.
Cool! I totally forget "..." operator, thanks AP.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement