I am facing a problem in void pointers in c++. Have a look at the following code:
#include<iostream.h>
int main()
{
void *ptr;
int x=3;
float y=2.35f;
char c='A';
ptr=&x;
cout<<endl<<*ptr; //line 1
ptr=&y;
cout<<endl<<*ptr;// line 2
ptr=&c;
cout<<endl<<*ptr;//line 3
cout<<endl;
return 0;
}
I am getting the errors of illegal indirection at line 1,2,3.Please help!!!