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 scope resolution operator in c++ with example?
What are enumerations?
What is null and void pointer?
Can create new c++ operators?
Name the debugging methods that are used to solve problems?
What are the vectors in c++?
What is the maximum value of a unsigned char a) 255 b) 256 c) 128
What is constructor c++?
What happens when you make call 'delete this;'?
Difference between a homogeneous and a heterogeneous container
Which compiler does turbo c++ use?
What is the most useful programming language?
How do I run c++?
Function can be overloaded based on the parameter which is a value or a reference. Explain if the statement is true.
Is c++ still being used?