5,321
edits
No edit summary |
(→Syntax) |
||
Line 61: | Line 61: | ||
You can also use them as class attributes, initializing them in the constructor's initializer list.<br> | You can also use them as class attributes, initializing them in the constructor's initializer list.<br> | ||
To store references in a vector, you can use <code>std::reference_wrapper</code> and include the <code>functional</code> header. | To store references in a vector, you can use <code>std::reference_wrapper</code> and include the <code>functional</code> header. | ||
====Types==== | |||
For simple programs, you can use the standard types: | |||
* <code>int</code>, <code>uint</code>, <code>long</code>, <code>size_t</code> | |||
* <code>float</code>, <code>double</code> | |||
See [https://stackoverflow.com/questions/6462439/whats-the-difference-between-long-long-and-long SO] for the standard and guaranteed precision of these built-in types. | |||
C++ also has fixed-width types in <code>#include <cstdint</code> (since C++11).<br> | |||
[https://en.cppreference.com/w/cpp/header/cstdint cppreference cstdint]<br> | |||
I recommend using these for anything with specific or high precision requirements.<br> | |||
Typically, I use: | |||
* <code>uint8_t</code> instead of <code>char</code> or <code>std::byte</code>.<br> | |||
* <code>int64_t</code> instead of <code>long long</code> | |||
===String=== | ===String=== |