question 8
why it will give compilatio error
the pointer can point to the next addresses and can give the result.
Pointers MCQ//////////////
@dakshi
Q8 Would the following program compile?
#include <iostream>
using namespace std;
int main() {
int a=10, *j; void *k; j=k=&a; j++;
k++; cout<<j<<k; return 0;
}
It will not compile as it will give the compilation error for line: j=k=&a; because there’s no implicit conversion from void* to type * in C++, so it will give you the error invalid conversion from ‘void*’ to ‘int*’
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.