Abstract class + Inheritance vs Interface

Posted by RealityDysfunction on Programmers See other posts from Programmers or by RealityDysfunction
Published on 2012-09-30T02:40:40Z Indexed on 2012/09/30 3:48 UTC
Read the original article Hit count: 411

Filed under:
|
|

Hello fellow programmers,

I am reading a book on C# and the author is comparing Abstract classes and Interfaces. He claims that if you have the following "abstract class:"

abstract class CloneableType
{
public abstract object Clone();
}

Then you cannot do this:

public class MiniVan : Car, CloneableType
{}

This, I understand. However he claims that because of this inability to do multiple inheritance that you should use an interface for CloneableType, like so:

public interface ICloneable
{
object Clone();
}

My question is, isn't this somewhat misleading, because you can create an abstract class which is "above" class Car with the method Clone, then have Car inherit that class and then Minivan will inherit Car with all these methods, CloneAble class -> Car class -> Minivan Class.

What do you think? Thanks.

© Programmers or respective owner

Related posts about c#

Related posts about interfaces