C++ Programming - References - Discussion

Discussion :: References - General Questions (Q.No.5)

5. 

Which of the following statement is correct about the references?

[A]. A reference must always be initialized within functions.
[B]. A reference must always be initialized outside all functions.
[C]. A reference must always be initialized.
[D]. Both A and C.

Answer: Option C

Explanation:

No answer description available for this question.

Shristy said: (Jun 2, 2015)  
Because if we will not initialize the reference, it will take garbage value.

Kushal said: (Jul 3, 2016)  
Its not necessary let it print garbage value.

Divya said: (May 30, 2017)  
Why, can any one explain it?

Prashant Srivastava said: (Jun 30, 2018)  
It will be compilation error if you don't initialize the reference at the point of declaration. for e.g

int main(void)
{
int a =11;
int &b;
}
The above code wont compile unless we put the statement as int &b =a; instead of int &b;

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.