Recall & Review
beginner
What is a reference in C++?
A reference is an alias for another variable. It allows you to access the same variable using a different name without copying it.
Click to reveal answer
beginner
Why do we need references instead of pointers?
References are safer and simpler to use because they must always refer to a valid object and cannot be null, unlike pointers.
Click to reveal answer
beginner
How do references help in function arguments?
References allow functions to modify the original variables passed to them without copying, improving performance and enabling direct changes.
Click to reveal answer
intermediate
What problem does using references solve in large data structures?
References avoid copying large data structures when passing them to functions, saving memory and time by working directly with the original data.
Click to reveal answer
beginner
Can a reference be changed to refer to another variable after initialization?
No, once a reference is initialized to a variable, it cannot be changed to refer to another variable. It always refers to the original object.
Click to reveal answer
What does a reference in C++ represent?
✗ Incorrect
A reference is an alias, meaning it refers to the same variable without making a copy.
Why are references safer than pointers?
✗ Incorrect
References must always refer to a valid object and cannot be null, reducing errors.
How do references improve function performance?
✗ Incorrect
References allow functions to work directly with original data, avoiding costly copies.
Can you reassign a reference to a different variable after initialization?
✗ Incorrect
References cannot be changed to refer to another variable once set.
Which of these is NOT a reason to use references?
✗ Incorrect
References cannot be null, so they are not used to create null variables.
Explain why references are useful when passing variables to functions in C++.
Think about how functions can change variables without making copies.
You got /3 concepts.
Describe the difference between a pointer and a reference in C++.
Focus on safety and how they refer to variables.
You got /4 concepts.