C++ References Question:
Download Questions PDF

What is output of this program?

#include <iostream>
using namespace std;
int main()
{
int a = 9;
int & aref = a;
a++;
cout << "The value of a is " << aref;
return 0;
}
a) 9
b) 10
c) error
d) 11

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

Answer:

b) 10

Download C++ References Interview Questions And Answers PDF

Previous QuestionNext Question
What is output of program?

#include <iostream>
using namespace std;
void print (char * a)
{
cout << a << endl;
}
int main ()
{
const char * a = "Hello world";
print(const_cast<char *> (a) );
return 0;
}
a) Hello world
b) Hello
c) world
d) compile time error
Which value we cannot assign to reference?
a) integer
b) floating
c) unsigned
d) null