C++ Primer
A deficient skyscraper engenders catastrophic consequences for the overall infrastructure.Consequently, the process of reacquainting oneself with the intricacies of C++ is an inevitable undertaking in the life of an algorithm engineer. Thus, it is advisable to desist from excessive discourse and instead focus on the practical implementation of the code.
The organization of the note diverges from that of the book, owing to the fact that a substantial portion of the knowledge I had previously acquired remains ingrained in my understanding.
I. Basic
2 Variables and Basic types
[ ] Basic Variable types and their storage
[ ] Type Conversions
In truncate part, will conversions be time-consuming? Considering that a double was calculated by the powers of 2, how can you convert?
[ ] When a type is unsigned, what is its range
[ ] Discuss the relationship between literals and types
[ ] WTF is a wide character. Wide characters' literals are
L'a'
This Warning is quite touching to me 'cause no one had ever noticed me of before.
3 Strings Vectors and Arrays
Strings and Vectors are widely used. String can be initialized in several ways.
3.1 Namespace
3.2 String
You can treat strings like basic types or objects(be careful not to use {})
It's pretty tricky that concatenating string using ""
, remembering left hand assign rule.
Strings has size()
and empty()
, not isempty()
. ehhh..
The reason is listed below:
Literals matter.
decltype(type)
good stuff if you don't know witch type.
To iterate char in string, copy/ change is different.
String table:
3.3 Vectors
I LOVE VECTORS
push_back()
makes a copy of the element.
This reminds me of Index Out of Bound in Java.
3.4 Iterator
Iterators are representatives of generic thinkings.
auto
++
*
Any Pointer(maybe ref) overloading * and ++ would be a iterator.
3.5 Arrays
The diff between arrays and vectors is that arrays have fixed size.
Thus, intuitively, arrays sometimes performs better than vectors.
3.6 Multi-D arrays
I've never seen of any code using multi-d arrays in c++.
It's because it's insufficient.
Like this explanation very much.