I got to know something about C++ when learning CS106X-Stanford and Object-Oriented Programming-Zhejiang University . However, I haven’t studied C++ specially. In this summer vacation, I will dig into C++ and keep some notes here.
The data structure part has been moved to the new post Data Structures and Algorithms Cheatsheet (C++). The remaining part of this post is mainly about language features.
Adding Literals and strings
For historical reasons, and for compatibility with C, string literals are not standard library
strings. It is important to remember that these types differ when you use string literals and library
When we mix
strings and string or character literals, at least one operand to each
+ operator must be of
string type. Thus, it is illegal to add two string literals. (
error: invalid operands to binary expression ('const char *' and 'const char *'))
!= rather than
Use iterators rather than subscripts.