string name;
cout<< name << endl;
Will the above statement display an object?
I was told that object. (class data member)
But here we are passing direct to a string object. And It works too. How?
string name;
cout<< name << endl;
Will the above statement display an object?
I was told that object. (class data member)
But here we are passing direct to a string object. And It works too. How?
Because string comes with an operator overload for << to do what you think it ought to.
operator<< (string) - C++ Reference
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.