lectures.alex.balgavy.eu

Lecture notes from university.
git clone git://git.alex.balgavy.eu/lectures.alex.balgavy.eu.git
Log | Files | Refs | Submodules

Constants in C++.md (405B)


      1 +++
      2 title = 'Constants in C++'
      3 +++
      4 # Constants in C++
      5 Why?
      6 
      7 If you know that a value will always be the same, the compiler can use that fact for optimisations. For example — it will always have the same size in memory, so the computer can use that memory for other things.
      8 
      9 Two options
     10 - `const` — declares an object as constant. Immutable once initialised.
     11 - `constexpr` — constant at compile-time