Would the following program compile?#include
using namespace std;
int main() {
int a=10, *j; void *k; j=k=&a; j++;
k++; cout<<j<<k; return 0;
}
Would the following program compile?
A) Yes
B) No
while the answer is NO.
why will this program not compile?
Mcq pointers doubt
It’s because of void *k , we can’t increment address of k which has been done by using k++
can we do this then?
int *a; cout<<a++; here int pointer is used right…so can we increment the address here…is it like void pointer cant be incremented or any pointer can be incremented
Void pointer is storing address of int variable and then we are also incrementing it. So it won’t be compiled.