InterviewSolution
Saved Bookmarks
| 1. |
What is a reference in C++? |
|
Answer» A reference is like a pointer. It is ANOTHER name of an already existing variable. Once a reference name is initialized with a variable, that variable can be ACCESSED by the variable name or reference name both. For example- int x=10;int &ref=x; //reference variableIf we change the VALUE of ref it will be REFLECTED in x. Once a reference variable is initialized it cannot REFER to any other variable. We can declare an array of pointers but an array of references is not possible. |
|