Re: Abstract class or interface?
- From: Jeff Louie <jeff_louie@xxxxxxxxx>
- Date: Sun, 01 May 2005 21:08:05 -0700
The simplest way to look at this is to understand that an interface is
functionally equivalent to a pure virtual abstract class. So an
interface is a
special case of an abstract class, one with no implementation. Given
that C#
only supports single inheritance of implementation and multiple
inheritance
of interfaces, then the question collapses to When should I use an
abstract
class with no implementation vs an interface? One answer is to use an
abstract class with no implementation when the interface is subject to
significant change. This allows you to add new methods with default
implementations to the base class without breaking existing clients of
the
base class. Another answer is to use an interface when classes may need
to
inherit from more than one interface. Another answer is to provide both
an
interface and an abstract class with default implementations of the
interface.
Regards,
Jeff
*** Sent via Developersdex http://www.developersdex.com ***
.
- References:
- Abstract class or interface?
- From: Brett
- Abstract class or interface?
- Prev by Date: Re: Invoke Error
- Next by Date: Re: Which is the best C# and .Net book
- Previous by thread: Re: Abstract class or interface?
- Next by thread: Re: Abstract class or interface?
- Index(es):
Relevant Pages
|