Answer the following statements true (T) or false (F)

1. A pointer is a variable that holds the address of some other location in memory.
2. Pointer variables are just memory addresses and can be assigned to one another without regard to type.
3. 3. The declaration below declares three pointer variables of type pointer to double that is, a pointer of type (double*)

double* p1, p2, p3;
4. A pointer is an address, an address is an integer, but a pointer is not an integer.
5. 5. You can get a pointer value to initialize a pointer variable from an object of an appropriate type with the “address-of” operator, &.


1. True
Computer memory is composed of addressable chunks of information called bytes. A pointer value is the memory address stored in a pointer variable.
2. False
A pointer variables, like everything else in C++ is typed, and that typing is enforced strongly. A pointer variable of type double* cannot normally hold a pointer value of type int* for example.
3. False
This declares one pointer variable, p1, and two double variables, p2 and p3. The * binds more closely to the variable, not to the type. In spite of this, the usually style puts the asterisk against the type.
To get three pointer variables, one must write
```
double *p1, *p2, *p3;
```
or better, declare the three pointer variables on separate lines
```
double* p1;
double *p2;
double *p3;
```
4. True.
Not crazy, rather this is an abstraction. The type system in C++ is sufficiently strong that it requires that you not assign pointer values to other types nor other types to pointers (without a cast, but that tells the compiler you know what you are doing, so it lets you.)
5. True
Every object has a value and an address. The & “address-of” operator extracts the address to make it available to initialize a pointer variable of appropriate type. Example: int x; int *ptrX = &x;

Computer Science & Information Technology

You might also like to view...

Which one of the following Button control names is not a legal C# identifier?

a. calculate Total Button b. print Sales Report Button c. clear_customer_names_button d. 1st Player Start Button

Computer Science & Information Technology

What is the most important thing to do when using a wireless network?

What will be an ideal response?

Computer Science & Information Technology

The organization method used to manage multiple data points within a dataset.

What will be an ideal response?

Computer Science & Information Technology

If you delete the only object on a layer, the layer is deleted as well.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology