Vidyalelo
C++ Programming · Q241

Classes and Objects in C++

Programming · C++ Programming · question 241

Q241

What happens when objects s1 and s2 are added? 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
Answer
D.
Run-time error

Answer: Option C

Solution

Answer: Option C
No explanation is given for this question Let's Discuss on Board