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;
}
Explanation
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.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести