Which version of the code will be compiled?
//1
double a = 2.71;
const int &b = a;

//2    
double a = 2.71;
int &b = a;
Explanation
A non-constant reference can only be assigned to an object of the same type as the reference type.

A constant reference can be assigned to an r-value or to an object whose type does not coincide with the reference type.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes