2025-09-24 notes code

Miscellaneous notes on C++ concepts, coming from a C background

Learning C++

Messy

This note is just a blob of personal notes on C++. Beware!!!

In summary,

Primary Resources

The C++ Programming Language (4th Edition) by Bjarne Stroustrup

The general ideals for design and programming can be expressed simply:
- Express ideas directly in code.
- Express independent ideas independently in code.
- Represent relationships among ideas directly in code.
- Combine ideas expressed in code freely – where and only where combinations make sense.
- Express simple ideas simply.

Effective Modern C++

Concepts

reference

move semantics and rvalue references

lvalue

int x = 5; // x is an lvalue
int* ptr = &x; // &x yields the address of an lvalue
*ptr = 10; // *ptr is an lvalue

rvalue

int y = 5; // 5 is an rvalue
int z = x + y; // x + y is an rvalue

vector

new and delete

constexpr

template

static initializers

list assignment

int i1 = 7.2; // i1 becomes 7
int i2 {7.2}; // error: floating-point to integer conversion
int i3 = {7.2}; // error: floating-point to integer conversion (the = is redundant)

range for loop

int v[] = {0,1,2,3,4,5,6,7,8,9};

// for each x in v
for (auto x : v)
	cout << x << '\n';

class

enum classes

separate compilation

namespaces

exceptions

invariant

static assertions

you can specify default arguments for functions

lifetime management