Which lines contain errors?
#include <string>

using std::string;

void test() {
  string s1 = "foo" "bar";  //1
  string s2 = "foo" + "bar";  //2
  string s3 = string("foo") + "bar";  //3
  string s4 = "foo" + string("bar");  //4
  string s5 = 'a';  //5
  string s6 = 'a' + 'b';  //6
}
Explanation
The second line contains two string literals, which is forbidden to do. For the fifth line, the std::string class does not have a suitable string(char) constructor; For the sixth line, the std::string class does not have a suitable string(int) constructor;

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes