Private vs Public inheritance
What is the exact difference between public and private inheritance?
what is the result of
class aClass : aBaseClass
{
};
is it public, private?
addititionally,
what are the conventions for implementing and interface and also deriving from some other base class?
example
class aClass: public aBaseClass, public IaInterface
{
};
or would you derive the IaInterface from the base class and use single inheritance?
Thanks
# 1 Re: Private vs Public inheritance
the default isn private inheritance for classes, public inheritance for structs.
As for interfaces: the conventional form is multiple public inheritance. An interface is often a struct that has only pure virtual member functions and no data members at all. You can also use virtual public inheritance to avoid ambiguity but that's a different issue.
Danny at 2007-11-11 20:59:33 >

# 3 Re: Private vs Public inheritance
You can find a detailed discussion about multiple inheritance and virtual inheritance here:
http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=167
http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=168
http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=169
Danny at 2007-11-11 21:01:33 >
