Values, Pointers and References in C++
Sun 28 November 2021
If you've primarily used high level languages like Python, you may not be used to explicitly thinking about the ownership or representation of your values in memory. In system languages like C++ or Rust, we have direct control over these aspects, and are able to use the type system to explicitly represent when a function takes ownership of a value, vs when it only takes a (temporary) reference.
First, different types of ownership, in order of preference:
T t
. A normal owned value of type T, uniqlue owned. If declared as a variable it is stored on ...