#include #include using namespace std; enum Pnum { eInt, eDouble,eString }; // create prototype of the funciton void useVoidPointer (){}; void useVoidPointer (void* vptr1, Pnum pType); int main () { int n1 = 12; double d1 = 24.25; string str1 ="Hello World"; useVoidPointer(&n1, eInt); useVoidPointer(&str1, eString); useVoidPointer(&d1, eDouble); return 0; } void useVoidPointer (void* vptr1, Pnum pType) { // uising switch switch(pType) { case eInt: cout <<" eInt : " << *static_cast(vptr1) << endl; break; case eDouble: cout <<" eDouble : " << *static_cast(vptr1) << endl; break; case eString: cout <<" eString : "<< *static_cast(vptr1) << endl; break; /* explict switch condition will not enter default value * default: cout<< " Value unknown"; */ } }