What happens when objects s1 and s2 are added?
Posted: Wed Jul 13, 2022 7:52 pm
string s1 = "Hello";
string s2 = "World";
string s3 = (s1+s2).substr(5);
a) Error because s1+s2 will result into string and no string has substr() function
b) Segmentation fault as two string cannot be added in C++
c) The statements runs perfectly
d) Run-time error
string s2 = "World";
string s3 = (s1+s2).substr(5);
a) Error because s1+s2 will result into string and no string has substr() function
b) Segmentation fault as two string cannot be added in C++
c) The statements runs perfectly
d) Run-time error