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
When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?
What c++ library is string in?
the first character in the variable name must be an a) special symbol b) number c) alphabet
Is multimap sorted c++?
Discussion on error handling of C++ .
Does c++ support exception handling?
What is the latest version on c++?
What new()is different from malloc()?
How do you decide which integer type to use?
What does floor mean in c++?
Declare a class vehicle and make it an abstract data type.
Am studying basic c++ programming, have been given the following assignment. Design a linear program to calculate the maximum stress a material can withstand given a force and a diameter of a circle. To find the required area pi should be defined. Have most of the program sorted out but am at a loss as to how to show the calculations required. Can anyone help?
What is token c++?
What is a constant reference?
Is turbo c++ free?