• Source
    1. #include <iostream>
    2. using namespace std;
    3. void increase (void* data, int type)
    4. {
    5. switch (type)
    6. {
    7. case sizeof(char) : (*((char*)data))++; break;
    8. case sizeof(short): (*((short*)data))++; break;
    9. case sizeof(long) : (*((long*)data))++; break;
    10. }
    11. }
    12.  
    13. int main ()
    14. {
    15. char a = 5;
    16. short b = 9;
    17. long c = 12;
    18. increase (&a,sizeof(a));
    19. increase (&b,sizeof(b));
    20. increase (&c,sizeof(c));
    21. cout << (int) a << ", " << b << ", " << c;
    22. return 0;
    23.  
    24. }