References
1.Writing multiple classes based on a template
-
A. A pointer to a variable
-
B. An alias for an existing variable
-
C. A constant variable
-
D. A type of function argument
An alias for an existing variable
An alias for an existing variable
2.Which of the following is the correct syntax for declaring a reference in C++?
-
A. int &a = b;
-
B. int &a b;
-
C. int a& = b;
-
D. int &a = b&;
int &a = b;
int &a = b;
3.What happens when a reference is initialized in C++?
-
A. It becomes a new variable
-
B. It must be assigned a new value
-
C. It must always refer to the same variable
-
D. It points to a memory location
It must always refer to the same variable
It must always refer to the same variable
4.Can you have a reference to a reference in C++?
-
A. Yes, it is allowed and commonly used
-
B. No, references cannot refer to other references
-
C. It is allowed, but only for pointer references
-
D. It is allowed only for classes
No, references cannot refer to other references
No, references cannot refer to other references
5. In C++, what is the output of the following code?
int a = 10;
int &b = a;
b = 20;
cout << a;
-
A. 10
-
B. 20
-
C. Compilation error
-
D. Runtime error
20
20