References
- What is the output of this program?
#include
using namespace std;
void print (char * str)
{
cout << str << endl;
}
int main ()
{
const char * str = "Interview Mania";
print(const_cast(str) );
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
In this program we used the concept of constant casting to cast the variable and printing it.
- What does a reference provide?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Because we are pointing memory address using the temp variable.
- What is the output of this program?
#include
using namespace std;
int main()
{
int num = 11;
int & numref = num;
num++;
cout << "The value of num is " << numref;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
The value is declared and it isincrementedrement, so it’s value is 11.
- What is the output of this program?
#include
using namespace std;
void swap(int &p, int &q);
int main()
{
int p = 5, q = 10;
swap(p, q);
cout << " In main " << p << q;
return 0;
}
void swap(int &p, int &q)
{
int temp;
temp = p;
p = q;
q = temp;
cout << "In swap " << p << q;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
As we are calling by reference the values in the address also changed. So the main and swap values also changed.
- Identify the correct sentence regarding inequality between reference and pointer.
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
we can not create the array of reference