C++ | References | Question 6
Which of the following is FALSE about references in C++
(A) References cannot be NULL
(B) A reference must be initialized when declared
(C) Once a reference is created, it cannot be later made to reference another object; it cannot be reset.
(D) References cannot refer to constant value
Answer: (D)
Explanation: We can create a constant reference that refers to a constant. For example, the following program compiles and runs fine.
#include<iostream>
using namespace std;
int main()
{
const int x = 10;
const int& ref = x;
cout << ref;
return 0;
}
Recommended Posts:
- C++ | References | Question 6
- C++ | References | Question 4
- C++ | References | Question 1
- C++ | References | Question 5
- C++ | References | Question 6
- References in C++
- Pointers vs References in C++
- Default Assignment Operator and References
- Can references refer to invalid location in C++?
- C++ | Misc C++ | Question 7
- C++ | Misc C++ | Question 8
- C++ | Inheritance | Question 14
- C++ | Misc C++ | Question 6
- C++ | Destructors | Question 5
- C++ | Inheritance | Question 10



