Hey guys, I have a question involving inheritance (hence the title xD). I'm trying to understand how initializing variables that a derived class inherits by calling the base classes constructor from the derived classes constructor works. This is the example I saw:
From what I understand, when the CCandyBox constructor2 is called it's creating a sub-object of a CBox class which is initialized with the values passed to CCandyBox's constructor, and the CCandyBox object is then inheriting these values into its inherited m_length, m_height and m_width members.
CCandyBox is a CBox, and more. In the derived class implementation, line 11 simply calls the constructor of the base class which fills out the "CBox" portion of the CCandyBox object.
(Your explanation has a level of indirection that is not actually present.)
Alright that makes sense. So when the CBox class is filling out the base class parts of CCandyBox it's filling it out with the values of lv, wv and hv. Makes sense :)