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
Explain the concept of dynamic allocation of memory?
What is a forward referencing and when should it be used?
Why can templates only be implemented in the header file?
Do you need a main function in c++?
What is difference between n and endl in c++?
What is late binding c++?
Const char *p , char const *p What is the difference between the above two?
Are c and c++ different?
Why is that unsafe to deal locate the memory using free( ) if it has been allocated using new?
What is class invariant in c++?
Is swift faster than go?
What is c++ hiding?
Differentiate between C and C++.
Explain how the virtual base class is different from the conventional base classes of the opps.
What is array give example?