C++ References Question:

Download Job Interview Questions and Answers PDF

Identify the incorrect statement:
a) reference is the alternate name of the object
b) A reference value once defined can be reassigned
c) A reference value once defined cannot be reassigned
d) none of the mentioned

C++ References Interview Question
C++ References Interview Question

Answer:

c) A reference value once defined cannot be reassigned

Download C++ References Interview Questions And Answers PDF

Previous QuestionNext Question
Can you please explain the difference between pass by value and pass by reference?What is the output of this program?

#include <iostream>
using namespace std;
void swap(int &a, int &b);
int main()
{
int a = 5, b = 10;
swap(a, b);
cout << "In main " << a << b;
return 0;
}
void swap(int &a, int &b)
{
int temp;
temp = a;
a = b;
b = temp;
cout << "In swap " << a << b;
}
a) In swap 105 In main 105
b) In swap 105 In main 510
c) In swap 510 In main 105
d) none of the mentioned