References Exercises

  < Previous  Next >
  1. Explain to your neighbor:
    1. What a C++ reference is
    2. What a C++ reference is not
    3. When should a reference be used (as compared to a pointer)
  2. What's the difference between (e.g., what do the calls looks like):
    int complexAlgorithm1(int* input);
    int complexAlgorithm2(int& input);
    
    1. Declare str as a std::string object
    2. Declare ex0 as a reference to str
    3. Assign "A SQL query enters a restaurant, walks up to two tables and asks, 'Can I join you?'" to ex0. What effect does this have?
    4. Declare ex1 as a reference to ex0. Explain to your neighbor what this does.
    5. Assign "I would tell you a UDP joke, but you might not get it" to ex1. What effect does this have?
    6. Write a function ex8 that takes a char reference named pc, increments it and returns it
    7. Write a function ex9 that takes an int reference named num, and prints out the value of num and a message saying if num is odd or even

Last Modified: