خرید بک لینک

Vote count: 0

I want a maintainable array/list of possible functions/behaviors, each representing another mode of operation, and I want to change the 'mode' simply by changing a variable storing the pointer to the right function.

With researching I found the fact, that function-pointers are a bit smelly, but I wonder if
A
it is okay in my usecase to use them anyway
B
there is a better/professional option.

Some pseudocode to show my prefered way of using it:

// store references to the modes and an information about the active mode
void * allModePointers[3];
int modeNumber = 2;

// call the active mode
(*allModePointers[modeNumber])();

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 21 خرداد 1395 ساعت: 7:08

صفحه بندی