click below
click below
Normal Size Small Size show me how
Pointers
| Question | Answer |
|---|---|
| Every variable has a data type, an address, and a value. In C++, you can obtain the address of a variable by using the ___________. | address operator, & |
| A ___________ is a variable used to store the address of another variable. | pointer |
| Pointers, like all C++ variables, must be ___________. | declared |
| The ___________ is used both to declare a pointer variable and to access the variable whose address is stored in a pointer. | indirection operator, *, |
| An array name is a pointer constant. The value of the pointer constant is the address of the ___________ element in the array. Therefore, if val is the name of an array, val and &val[0] can be used interchangeably. | first |
| Any access to an array element with subscript notation can always be replaced with ___________ notation. That is, the notation a[i] can always be replaced by the notation *(a + i). This is true whether a was initially declared as an array or a pointer. | pointer |
| Arrays can be created ___________ as a program is running. For example, the following sequence of statements creates an array named grades of size num: cout << "Enter the array size: "; cin >> num; int *grades = new int[num]; | dynamically |
| The area allocated for the array can be ___________ dynamically by using the delete[] operator. | destroyed |
| Arrays are passed to functions as ___________. The called function always receives direct access to the originally declared array elements. | addresses |
| When a one-dimensional array is ___________ to a function, the function’s parameter declaration can be an array declaration or a pointer declaration. Therefore, the following parameter declarations are equivalent: double a[]; double *a; | passed |