Having the vairable of type string, which lines will cause compilation errors?
#include <iostream>
#include <string>

using namespace std;

int main()
    string s1;
    s1 = "dasda"; //1
    cout << s1 << endl; //2
    cout << s1[2] << endl; //3
    s1 = 'a'; //4
    s1 = &s1; //5
    return 0;
std::string does not have a constructor and assignment operator, taking a pointer to std::string, so on the line 5 will be a compilation error.

Follow CodeGalaxy

Mobile Beta

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