Doubt in Question 8

Why does the program snippet given in que 8 does not compile?

@rahul.maheshmaheshwari hey rahul I think is that conversion of data type is difficult so compilation is not possible in this case.

can you please elaborate a little more?

@rahul.maheshmaheshwari
This is the code snippet :
int a = 10, *j;
void *k;
j = k = &a;
j++;
k++;
cout << j << k;

As you can see , we are trying to increment k with k++; k is a void* object. Pointers to void cannot be incremented as their increment level would not be defined hence this program will not compile.

Thanks for the clarification.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.