Why we use Reference Variables Give one example-00209

Online Quiz This subjective question is related to the book/course vu cs101 Introduction to Computing. It can also be found in vu cs101 Mid Term Solved Past Paper No. 2.

Question 1: Why we use Reference Variables. Give one example.
Answer:

C++ references allow you to create a second name for the a variable that you can use to read or modify the original data stored in that variable.

main() {
int x;
int& foo = x;
// foo is now a reference to x so this sets x to 56
foo = 56;
std::cout << x <<std::endl;
}

Choose an organization

Theme Customizer

Gaussian Texture



Gradient Background