Can there be two std::string a and std::string b strings for which a == b returns true , but they have a different appearance when std::cout << a << b ?
- if two objects have different values, they cannot be equal, unless these objects are not of a user type, for which the == operator is defined differently - AR Hovsepyan
- @ARHovsepyan I ask about the presentation on the screen, can it be different? - stat
- Dear stat, I do not really understand you, because the value is displayed on the screen (console or any other stream). If you mean the size or shape of the font, then it does not matter ... - AR Hovsepyan
- one@stat, I'm not sure that there are consoles in which you can change the codepage for part of the output. Purely theoretically, you can write this, just what's the point? Anyway, my hands will have to change. - ixSci
- 3Just for the future: you are better in the question immediately indicate the real problem, it will be easier to understand each other. - ixSci
|
1 answer
They can not, because operator<< for a line must take into account the entire line (begin, end), just as operator== takes into account the entire line through data() & size() , i.e. no tricky tricks with adding somewhere \0 will not work. And the rest, std::string is a set of char , and if one set of char is identical to the other, then both sets will be output to the output device in the same way.
|