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
Is overriding possible in c++?
What is c++ and its uses?
Describe the syntax of single inheritance in C++?
What is a singleton class c++?
what is oops and list its features in c++?
What is the difference between an external iterator and an internal iterator?
What is a c++ class?
Explain public, protected, private in c++?
Where must the declaration of a friend function appear?
Which programming language's unsatisfactory performance led to the discovery of c++?
Write a c program for binary addition of two 8 bit numbers.
Why main function is special in c++?
What is array in c++ example?
What size is allocated to the union variable?
Is c++ still being used?