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


Please Help Members By Posting Answers For Below Questions

What is a modifier in c++?

719


Does dev c++ support c++ 11?

652


Write a function to find the nth item from the end of a linked list in a single pass.

655


Is overriding possible in c++?

647


How would you differentiate between a pre and post increment operators while overloading?

738






Explain the static member function.

815


What is the difference between global variables and local variable

616


When does the c++ compiler create temporary variables?

666


Is map thread safe c++?

741


Does a derived class inherit or doesn't inherit?

718


How much do c++ programmers make?

646


Is ca high or low level language?

669


What are abstract data types in c++?

649


What is meant by the term name mangling in c++?

608


C is to C++ as 1 is to a) What the heck b) 2 c) 10

743