Will it make any difference whether we inherit the class first or interface in C++?
example:
class A : public IAbstract, public ClassB
{
};
class A : public ClassB, public IAbstract
{
};
                The initialization order of direct base classes (i.e. ClassB and IAbstract) will be different. It's determined by the declaration order in base class specifier list.
(emphasis mine)
2) Then, direct base classes are initialized in left-to-right order as they appear in this class's base-specifier list
Yes the object layout will be different. Functionally however, it's equivalent.
In the first case, the object layout will be something like this:
------
IAbstract members, including vptr
------
Class B members
------
And in the second case:
------
Class B members
------
IAbstract members, including vptr
------
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With