Basic Lines of Code in C++
- Types
int,int32_t,int64_t,double
- Variables
int n = 42;auto n = 42;const auto n = 42;vector<string> words;matrix<double> mat;unordered_map<string, contact_info> contact_info_for_id;
- Functions
auto multiply(int a, int b) -> int { return a * b; }auto print(const contact_info& a) { ...; }auto concat(const string_view a, const string_view b) -> string { return ...; }
- Loops
for (int i = 1; i <= 10; ++i) { ...; }for (size_t i = 0; i < words.size(); ++i) { ...; }for (int i : {5, 7, 11, 13}) { ...; }for (const auto& word : words) { ... }
Note
In C++intand42are typically 32 bits wide, not 64 bits.