Quote:
Originally posted by palette
Hi,
Could someone please tell me , that if I've a function that takes a void* as an argument, then, is there any way to know, exactly which type of pointer has been passed by the calling function.
e.g.
int main()
{
int i=5;
func(&i);
char c='c';
func(&c);
}
void func(void* p)
{
// How can I know here, whether to cast p as int*, or char* to read the correct values ??
}
You can't, well not that I know of. Why don't you make 2 functions OR use templates. Look them up on google or here if you need further explanation.