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 are the syntactic rules to be avoid ambiguity in multiple inheritance?
Is c++ used anymore?
Specify some guidelines that should be followed while overloading operators?
What is the role of static keyword for a class member variable?
If dog is a friend of boy, is boy a friend of dog?
What is a .lib file in c++?
What is meant by const_cast?
What is a c++ object?
What is #include iostream in c++?
Differentiate between a constructor and a method in C++.
What methods can be overridden in java?
Explain the difference between using macro and inline functions?
Explain the difference between static and dynamic binding of functions?
What is c++ in english?
Difference between pointer to constant and constant pointer to a constant. Give example.