Question: . A pointer variable can contain a pointer to a valid object, a pointer to a deleted object, NULL, or a random value. Write code
. A pointer variable can contain a pointer to a valid object, a pointer to a deleted object, NULL, or a random value. Write code that creates and sets four pointer variables a, b, c, and d to show each of these possibilities. What happens when you dereference each of the four pointers that you created? Write a test program if you are not sure.
#include
void pointer() {
int* a;
int* b;
int* c;
int* d;
int x = 123;
a = &x; int* bObj = new int(456);
b = bObj; delete bObj;
c = NULL;
d = (int*)123456;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
