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;
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / pokala
world! world! is the right anwer.
Do not confuse with other asnwers.
Same is verified.
| Is This Answer Correct ? | 3 Yes | 0 No |
int main() { int i ,a[i]; i = 0; a[i] = 10; cout<< a[i] << endl; return 0; } What will be output of this program?
How can I learn c++ easily?
What is a dangling pointer?
What does asterisk mean in c++?
Can we inherit constructor in c++?
How a new operator differs from the operator new?
What are the different types of polymorphism?
What is a forward referencing and when should it be used?
let a,b,c be three integer numbers.write a c++ program with a function void rotate 1()such that a->b->c and c->a.
Why null pointer is used?
Explain unexpected() function?
Why do we need templates?