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;
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / pokala
world! world! is the right anwer.
Do not confuse with other asnwers.
Same is verified.
| Is This Answer Correct ? | 3 Yes | 0 No |
Implement strcmp
What are the characteristics of friend functions?
How is computer programming useful in real life?
What do you mean by public protected and private in c++?
What is time_t c++?
What is an adaptor class or Wrapper class?
Can we use clrscr in c++?
What is the importance of mutable keyword?
What are the three types of access specifiers in C++?
Explain all the C++ concepts using examples.
You're given an array containing both positive and negative integers and required to find the sub-array with the largest sum (O(N) a la KBL). Write a routine in C for the above.
what is a reference variable in C++?