Re: Class Inheritance vs Interface Inheritance
"John" <john@microsoft.discussions.com> wrote in message
news:O2XXYi#ZJHA.4480@TK2MSFTNGP06.phx.gbl...
Hi Alex/Ben,
I am going through design patterns book by GoF. I asked about regular
C++ inheritance only.
With the caveat that you must explicitly define your interface if you
want interface inheritance, there is no way to re-implement the interface
of a concrete class without inheriting the implementation as well
I think, we can achieve this with Pure Virtual functions. If answer
No, please provide the details how to do it.
In C++, you always get whatever behavior the base class had. Pure virtual
functions have no implementation, so then you have interface implementation
in effect.
Some languages let you request to inherit only the interface even when the
base class does have behavior defined. C++ does not, so you need an extra
class, having only interface, to inherit from.
Thanks,
John.
"Alex Blekhman" <tkfx.REMOVE@yahoo.com> wrote in message
news:%23ctnR16ZJHA.5676@TK2MSFTNGP03.phx.gbl...
"Ben Voigt [C++ MVP]" wrote:
With the caveat that you must explicitly define your interface if you
want interface inheritance, there is no way to re-implement the
interface of a concrete class without inheriting the implementation as
well (unlike VB6 for example which always does interface inheritance and
is incapable of inheriting behavior).
Either I'm too slow or too tired or both, but the original question
sounds quite vague to me. I am not sure what exactly John tries to ask.
Is it about regular C++ inheritance or some other kind of inheritance?
Alex