Why cout<<"Hello world" + 10; prints d in the output

Viewed 53
int main(){
    string s = "";
    s += 1;// if I do s = s + 1 code doesn't compile
    cout<<"Hello world"+10<<endl;
    cout<<s<<endl;
}

Why it prints d and random character. I try to think it as string is a char* then if I do str + 10 then it points to the 10 pos. I am not sure I am correct or not.

0 Answers
Related