Classes in Sub-Objects

Was hoping to get feedback on the following scenario -

"for the class declarations below, how many sub-objects of type Base1 are there?"

-----------


class Base1 {};

class Deriv1 : virtual public Base1{};

class Deriv2 : virtual public Base1{};

class DerivDeriv1 : public Deriv1, public Deriv2, virtual public Base1;
All 3 of those child classes derive from Base1 virtually, so any object of any of those types will have exactly 1 instantiation of a 'Base1'.
OK - that's consistent with what I thought. Although, you could say technically there is a single object and zero sub-objects, as ascribe the phrase sub-object to an instance that inherits from a base class. However of the choices offered - zero was not an option, so I went with one.
Last edited on
Topic archived. No new replies allowed.