Interface vs. Abstract
classes
Abstract class needs to have at least one "pure
virtual method" *
In case of Interface all the methods should
be "pure virtual"
An Abstract class can have all methods as
"pure virtual" and still it will
not allow multiple
inheritance... With Interface multiple inheritance is
possible
in .Net...
Various access modifiers such as abstract,
protected, internal, public,
virtual, overrides etc are not
useful in case of Interface but they are in
case of Abstract
classes
Class implementing Interface has to implement all
the methods of the
Interface, this is not required in case of
Abstract classes
As Interface cannot be instantiated, they
do not have constructors and
destructors like the way Abstract
classes can...
Interface cannot contain a static method
whereas an Abstract class can
have...
There are few
more points which I can recollect but I think that this
is
enough for a tip... If anyone needs more info do write back
to me... :-)
* pure virtual method is a method which
has just definition but
not
implementation...
****************************************************************************
****************************************************************************
*******************************************
An
addition to yesterday's tip... We cannot access static member of a
class
using object of a class in C#, though this is possible in
VB.Net... Thanks
to Jacob Cynamon, MS & Kathleen Dollard,
MVP for quickly reminding the
same... Thanks all for sending a
wonderful queries & feedbacks and making
my evenings more
useful...
****************************************************************************
****************************************************************************
*******************************************
PS:
Many of us work on weekends, I don't think (current thought!!)
that its
a good practice doing that, at least if you are being
gauged on the basis of
your willingness to work on weekends
then its surely very bad... I am trying
to start a movement to
abolish this social evil of working on weekends, so
no tips on
weekends...:-)
BONUS TIP: Spend time with your family this
weekend... :-)
Tuesday, June 29, 2004
Interface vs. Abstract classes
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment