Why this shows error:
int a=10;
int *y;
void *z;
y = z = &a;
And this doesn’t:
int a=10;
int *y;
void *z;
z = y = &a;
Why this shows error:
int a=10;
int *y;
void *z;
y = z = &a;
And this doesn’t:
int a=10;
int *y;
void *z;
z = y = &a;
This is because assignment takes place from right to left. And in C++ a void pointer cannot be directly assigned to other type pointers so there is a error in first case. But as a generic(void) pointer can be assigned a pointer value of any basic data type so there is no error in second case.
To remove error in the first case cast operator can be used.