Exercises


  • Create a pointer, use new to give it something to point to, and assign the pointed-to variable a number.
  • Consider the following program:
    #include <iostream.h>
    
    void main(void)
    {
      int *taco;
      int *burrito;
    
      taco = new int;
    
      burrito=taco;
    
      *taco = 10;
    
      cout << "Taco is set to " << *taco << endl;
      cout << "Burrito is set to = " << *burrito << endl;
    }
    
    What do you think the output of the above program is? Why do you think that happened?


Table of Contents

Pointers | Pointer Operations | More Pointer Issues | Deleting Variables
Checking for Nothing | Exercises