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
How a macro differs from a template?
Name the operators that cannot be overloaded in C++?
What is class and structure in c++?
What are disadvantages of pointers?
What are the uses of pointers?
Show the declaration for a static function pointer.
Is swift better than c++?
Write a note about the virtual member function?
what is data abstraction in C++?
What do you mean by function and operator overloading in c++?
Why is c++ considered difficult?
What is a friend function in c++?
What are 2 ways of exporting a function from a dll?
What is the difference between new() and malloc()?
Can we specify variable field width in a scanf() format string? If possible how?