M.2 — R-value references

Way back in chapter 1, we mentioned l-values and r-values, and then told you not to worry that much about them. That was fair advice prior to C++11. But understanding move semantics in C++11 requires a re-examination of the topic. So let’s do that now. L-values and r-values Despite having …

13.17 — Nested types in classes

Consider the following short program: #include <iostream> enum class FruitType { apple, banana, cherry }; class Fruit { private: FruitType m_type {}; int m_percentageEaten { 0 }; public: Fruit(FruitType type) : m_type { type } { } FruitType getType() const { return m_type; } int getPercentageEaten() const { return m_percentageEaten; …