The correct answer is A. agePtr = &age;
A pointer is a variable that stores the address of another variable. The statement agePtr = &age;
assigns the address of the variable age
to the pointer variable agePtr
. This means that agePtr
now points to the variable age
.
The statement agePtr = *age;
would dereference the pointer agePtr
and assign the value of the variable pointed to by agePtr
to agePtr
. This would not assign the address of age
to agePtr
.
The statement &agePtr = age;
would assign the address of the pointer agePtr
to the variable age
. This would not assign the address of age
to agePtr
.
The statement *agePtr = age;
would dereference the pointer agePtr
and assign the value of the variable pointed to by agePtr
to the variable age
. This would not assign the address of age
to agePtr
.
The statement agePtr -> *age;
is not valid C++ syntax.