# Self test 1

## Reference Types <a href="#id-0f93ca9a88884bd392bb1e14eec4cf2d-problem-title" id="id-0f93ca9a88884bd392bb1e14eec4cf2d-problem-title"></a>

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 <a href="#id-99e170e9df83459da97f34b5aa4afe9c-problem-title" id="id-99e170e9df83459da97f34b5aa4afe9c-problem-title"></a>

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 <a href="#id-971bf186b06e4794bcd5143c41ea0d9f-problem-title" id="id-971bf186b06e4794bcd5143c41ea0d9f-problem-title"></a>

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
  \*
