Object Oriented Programming

1:

The following program fragment   
void main ( )
{
int x=10;
int &p=x;
cout << &p <<  &x;
}      

A.

prints 10 and the address of x

B.

prints the address of p twice

C.

prints the address of x twice

D.

Both (b) & (c)

 

Answer : D

Explanation :

int &p=x aliases p to x. This means they refer to the same memory location. So, the address of x will be same as that of p.

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.