I'm new to C++ and was learning about string concepts and was just experimenting around. I have the following code:
int main(){
string s1="loc";
string s2="al var";
cout<<s1.append(s2)<<endl<<s1<<endl<<s1+s2;
}
Running it in Vs-code I get the output as:
local var
local var
local var
What I don't understand is I append s1 with s2 and it prints as "local var". Then I print s1 and get the output "local var" meaning s1 is updated successfully. But when I print s1+s2 I don't know why it still gives the same output as s1 and s2 isn't being concatenated with s1 in the output. I was expecting answer as "local varal var. I want to know about how and why is this happening.
Thanks!