About that part:
Note that it doesn’t matter where in the Derived constructor initialization list the Base constructor is called -- it will always execute first.
If i do
1 2 |
Derived(double cost=0.0, int id=0) : m_cost(cost), Base(id) |
then i get warnings
1 2 3 4 5 6 7 8 9 10 |
main.cpp: In constructor 'Derived::Derived(double, int)': main.cpp:20:12: warning: 'Derived::m_cost' will be initialized after [-Wreorder] double m_cost; ^~~~~~ main.cpp:23:32: warning: base 'Base' [-Wreorder] : m_cost(cost), Base(id) ^ main.cpp:22:5: warning: when initialized here [-Wreorder] Derived(double cost=0.0, int id=0) ^~~~~~~ |
Worth noting in the same paragraph?