Answer the following statements true (T) or false (F)
1. One can use the & operator to extract the value that a pointer points to.
2. When declaring several pointer variables, there must be one pointer declarator * for each pointer variable.
3. Dangling pointers present no problem in C++
4. Dynamic variables or dynamically allocated variables in C++ are created and destroyed according to the program’s needs.
5. There should eventually be a call to the operator delete on a pointer that
points to the memory allocated by each call to new.
1. False
The operator is the dereferencing operator, *. This says “follow the pointer to the storage place” or “the variable pointed to by …”
2. True
Consider this definition of p1, p2 and p3 as pointer to doubles:
```
double *p1, *p2, *p3;
```
There must be one * for each pointer variable defined.
3. False
A dangling pointer occurs when several pointers point to the same chunk of allocated freestore memory. If one of the pointers has had the delete
pointer applied to it, releasing the freestore memory, the other pointers are said to be dangling. Because the pointer that had delete applied to it most of the time isn’t
changed by the delete operation (not guaranteed by any means), a deleted pointer is frequently called a ‘dangling pointer.’
4. True
Dynamic variables are unaffected by function calls or function return. This is not true of local pointer variables that may point to dynamic variables. Consequently, in a poorly written program, a local pointer can go out of scope and the dynamic variable to which the pointer points may be lost.
5. True
Pointer variables are usually local variables. Memory allocated on the free store using the new operator remains allocated whether you use it or even have a pointer pointing to it. If the pointer that points to the allocated memory dies with the end of a function or a block, the memory allocated is locked away so that no one can use it until the program terminates.
You might also like to view...
A simple scheme for relocating programs in multiprogramming environments involves the use of a single relocation register.All programs are translated to locations beginning at zero, but every address developed as the program executes is modified by adding to it the contents of the processor’s relocation register. Discuss the use and control of the relocation register in variable-partition multiprogramming.
What will be an ideal response?
The margin and padding shorthand properties may contain ____ values.
A. one B. three or four C. two D. all of the above
The SUBTOTAL function includes hidden records and only uses visible filtered records to calculate the formula
Indicate whether the statement is true or false
One kilobyte (K or KB) equals approximately ____ memory locations
A. 100 B. 1,000 C. 10,000 D. 100,000