C++ Quiz Questions Set 2

1) What is the out put?
void main()
{
 int a, *pa, &ra;
 pa = &a;
 ra = a;
 cout << "a=" << a << "*pa=" << *pa << "ra=" << ra;
}
Answer:
Compiler Error: 'ra',reference must be initialized

Explanation:
Pointers are different from references. One of the main differences is that the pointers can be both initialized and assigned, whereas references can only be initialized. So this code issues an error.

1 comment:

  1. It is nice blog Thank you provide important information and i am searching for same information to save my time Big data hadoop online Training

    Splitwise
    appvn

    ReplyDelete