Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
  1. A pointer variable can store __________ .
  • integer values
  • double values
  • addresses of other variables
  • string values
  1. In order to determine the address of a variable in C++, we can use the __________ operator.
  • @
  • ++
  • *
  • &
  1. Pointer variables must always be __________ before they are used.
  • dereferenced
  • static
  • initialized
  • checked
  1. In order to follow a pointer and access the data it is pointing to, we must __________ the pointer using the __________ operator.
  • use, @
  • access, &
  • dereference, *
  • reference, *
  1. Pointer can be used to dynamically allocate storage from the __________ at __________.
  • stack, compile-time
  • stack, run-time
  • heap or free store, run-time
  • heap or free store, compile-time
  1. When using raw pointers and dynamica storage allocation, we must always de-allocate the used storage by using __________ to prevent __________.
  • delete, memory leaks
  • free, buffer overruns
  • delete, stack overflows
  • new, memory leaks
  1. __________ and pointers can be used interchangeably in many contexts.
  • Function calls
  • Classes
  • Vectors
  • Array names
  1. What types of variables can ptr store given the following declaraion below? int **ptr;
  • integers
  • addresses of integers
  • addresses of pointers to integers
  • any type of integer
  1. What does the following code snippet display?
int *data = new int[5];

for (int i=0; i<5; i++)
    *(data + i) = i*2;

for (int i=0; i<4; i++)
    cout << data[i] << " ";
cout << endl;

delete [] data;
  • 0 1 2 3 4
  • 0 2 4 6 8
  • 2 4 6 8 10
  • garbage data
  1. Given the following pointer decalrations, what can you say about ptr1 and ptr2?
int *ptr1;
int *ptr2 {nullptr};
  • ptr1 and ptr2 are both contains the address 0
  • ptr1 and ptr2 are both initialized
  • ptr1 is uninitialized and ptr2 is initialized
  • ptr1 and ptr2 are both uninitalized