W
WittyGuy
How to typecast a "function pointer" to "const void*" type in C++ way?
int MyFunction (double money); // Function prototype
const void* arg = (const void*)MyFunction; // type casting function
pointer to const void* in C-style
void(*pFunc)() = (void(*)())(arg); // type casting const void* to function
pointer in C-style
(*pFunc)(); // Calling the function after type casting is done
Is typecasting like above is safe anyway?
regards,
Sukumar
int MyFunction (double money); // Function prototype
const void* arg = (const void*)MyFunction; // type casting function
pointer to const void* in C-style
void(*pFunc)() = (void(*)())(arg); // type casting const void* to function
pointer in C-style
(*pFunc)(); // Calling the function after type casting is done
Is typecasting like above is safe anyway?
regards,
Sukumar