Self test 1
Reference Types
Which of the following is a valid way to create an alias for a variable in C++? Note that data types are excluded for simplicity.
&refVariable = variable RIGHT
*refVariable = variable //derefrence; assign value hold by pointer refVariable by variable
refVariable = &variable //refVariable should be a pointer, point to address of variable
refVariable = *variable //refVaribale takes value hold by pointer variable
Passing Reference Types
What is the side-effect of passing a reference type into a function?
You have to know the data type before passing a reference type
Modifying the reference in the function modifies the value in memory RIGHT
Modifying the reference in the function only modifies a copy of the value
You must use the ref keyword in the function prototype
Pointer Variables
Why must you provide a data type for a pointer variable even though pointer variables only store memory addresses?
The complier needs to know how much to request for any value that will be stored in that memory location RIGHT
The compiler will create a temporary value of that type and store it in the memory location to prevent it being overwritten
It isn't necessary NOT RIGHT
It let's other programmers know what data to store in that pointer NOT RIGHT
Last updated