What is the output of:
String a1 = "Hello";
String a2 = "world!";
String* s1 = &a2;
String& s2 = a1;
s1 = &a1;
s2 = a2;
std::cout << *s1 << " " << s2 << std::endl;
Answer Posted / ratan
The output is
world! world!
This is becuase s2 is a reference variable of a1 and we are
assigning s2 value if a2 which is world!.
This is chnaging the value at a1 as well.
| Is This Answer Correct ? | 8 Yes | 0 No |
Post New Answer View All Answers
What is the main purpose of overloading operators?
What is the need of a destructor? Explain with the help of an example.
What are manipulators used for?
What is called array?
Explain 'this' pointer and what would happen if a pointer is deleted twice?
Is it possible to provide default values while overloading a binary operator?
What are the characteristics of friend functions?
What is decltype c++?
Can I learn c++ without learning c?
What is c strings syntax?
Is set c++?
Why c++ is so important?
Write a single instruction that will store an EVEN random integer between 54 and 212 inclusive in the variable myran. (NOTE only generate EVEN random numbers)
What is an accessor in c++?
What is a modifier in c++?