Void Pointer

I m a beginner need a help in void pointer.
In the program given below can u explain what does pint=(int*)data; means in function increase.

#include <iostream>
using namespace std;

void increase (void* data, int psize)
{
if ( psize == sizeof(char) )
{ char* pchar; pchar=(char*)data; ++(*pchar); }
else if (psize == sizeof(int) )
{ int* pint; pint=(int*)data; ++(*pint); }
}

int main ()
{
char a = 'x';
int b = 1602;
increase (&a,sizeof(a));
increase (&b,sizeof(b));
cout << a << ", " << b << endl;
return 0;
}

Thanks for help :)
A void pointer has no specific type and can be cast to any type of pointer.
In your case, the void pointer data is cast to an int pointer, to fit the type of pint, and gets loaded into pint.
Thanks for help wjee0910.
Topic archived. No new replies allowed.