Recall & Review
beginner
What is a reference in C++?
A reference is an alias for another variable. It must be initialized when declared and cannot be changed to refer to another variable later.
Click to reveal answer
beginner
What is a pointer in C++?
A pointer is a variable that stores the memory address of another variable. It can be reassigned to point to different variables.
Click to reveal answer
intermediate
Can a reference be null in C++?
No, a reference must always refer to a valid object. It cannot be null.
Click to reveal answer
intermediate
Can a pointer be null in C++?
Yes, a pointer can hold a null value, meaning it points to no object.
Click to reveal answer
beginner
How do you access the value pointed to by a pointer?
You use the dereference operator (*) to access or modify the value the pointer points to.
Click to reveal answer
Which of the following must be initialized when declared?
✗ Incorrect
References must be initialized when declared; pointers can be declared without initialization.
Can a pointer be reassigned to point to a different variable?
✗ Incorrect
Pointers can be reassigned to point to different variables anytime.
Which can be null in C++?
✗ Incorrect
Pointers can be null; references cannot.
How do you access the value a pointer points to?
✗ Incorrect
The * operator dereferences the pointer to access the value.
Which statement about references is true?
✗ Incorrect
References act as aliases and cannot be changed to refer to another variable after initialization.
Explain the main differences between a reference and a pointer in C++.
Think about initialization, nullability, and how you use them.
You got /4 concepts.
Describe a situation where you would prefer to use a pointer over a reference.
Consider flexibility and nullability.
You got /4 concepts.