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 a modifier in c++?
Does dev c++ support c++ 11?
Write a function to find the nth item from the end of a linked list in a single pass.
Is overriding possible in c++?
How would you differentiate between a pre and post increment operators while overloading?
Explain the static member function.
What is the difference between global variables and local variable
When does the c++ compiler create temporary variables?
Is map thread safe c++?
Does a derived class inherit or doesn't inherit?
How much do c++ programmers make?
Is ca high or low level language?
What are abstract data types in c++?
What is meant by the term name mangling in c++?
C is to C++ as 1 is to a) What the heck b) 2 c) 10