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 format for defining a structure?
What is the use of c++ programming language in real life?
What is the latest c++ version?
What is c++ & why it is used?
How does a copy constructor differs from an overloaded assignment operator?
What are the advantages of prototyping?
Can I learn c++ without c?
Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. Your program should work for squares of all side sizes between 1 and 20. --- │ │ │ │ │ │ ---
What is the use of lambda in c++?
Give example of a pure virtual function in c++?
Why should we use null or zero in a program?
Is map sorted c++?
Which programming language's unsatisfactory performance led to the discovery of c++?
what is scupper?
What is the best free c++ compiler for windows?