Object Oriented Programming

1:

The following program segment
int a = 10 ;
int const &b = a ;
a = l1 ;
cout << a <<  b ;      

A.

results in compile time error

B.

results in run time error

C.

prints 1111

D.

none of the above

 

Answer : C

Explanation :

The very idea of declaring b as a constant integer is to protect it from changes. However, since it is aliased to a variable whose attribute is not const, the value of b can be indirectly changed by changing the value of a. This is a bad programming practice.

Write your comments here:


Report Error
 

Option: A

Explanation : Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here.