Re: Confuesd about abstract class vs interface

From: Chuck Bowling (chuckbowling_at_sbcglobal-NO-SPAM.net)
Date: 12/22/04


Date: Wed, 22 Dec 2004 11:22:28 -0500

An abstract class is kind of like a new car. You start out with a basic no
frills car (your abstract class), then you add too it - superduper radio,
custom paint, nice wheels. That's inheritance. You inherited the basic car
and added features via your inheriting class.

An interface is a promise that your class will implement a set of methods
specified by the interface. An instance of a class that uses another class
containing an interface knows that it can rely on that class to provide
functions promised by the interface.

"phl" <killkennyhouse@hotmail.com> wrote in message
news:1103715301.228141.162380@f14g2000cwb.googlegroups.com...
> hi,
>
> I am kind of confused aobut interfaces and abstract classes.
>
> In short as I understand it, an interface is like a contract between
> the class and the interface, so that certain funtions must be
> implemented. So if you have a class which inherits base class that
> inherts an interface, then your classes will have a standard. I suppose
> you can also check for interface at run time say when dll is loaded and
> see if it implememts whats required by interface also before loading
> it.
>
> I have never used abstract classes, as I understand it, its for
> creating a base class with function without any implementation, so that
> it can be done in your inherited class. I am confused why you would
> need this, as you already can override functions and also theres
> interfaces.
>
> I have probably misunderstood something, can someone please explain.
> The reason i am interested is because I am writing a system which i
> hope to be well maintained in the future. I want other people to add
> classes with specific implementations.
>
> thanks
>



Relevant Pages

  • Re: Concrete class
    ... >> abstract class with ALL pure virtual functions. ... >> above philosophy then it means that your Shape is an interface. ... > of doing this is to keep the inheritance hierarchy at a low depths" is ...
    (comp.lang.cpp)
  • Re: Abstract class or interface?
    ... Abstract classes require and imply inheritance whereas interfaces do not. ... An abstract class would be used wherever it was important to enforce some ... aspect of the implementation an interface is used where only the agreement ... > derived classes can only inherit one abstract class. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Declaring a Constructor in an Interface?
    ... i have read many places that an interface is faster than ... but would You also claim that an abstract class ... Dennis JD Myrén ... > Virtual methods always means performance overhead. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: A Java "interface" declaration does not allow a constructor to be specified in it ...
    ... > If Java supported full multiple inheritance (which is ... > the implication of interface constructors), ... abstract class MailDelivery has a non-abstract method "transport", ...
    (comp.lang.java.programmer)
  • Re: Java/J2EE Openings in RTP, NC
    ... JSP, EJB, DAO Developer ... An abstract class is declared with the keyword "class" and is an implementation, i.e., its methods can contain bodies. ... An interface is a declaration of public method signatures which taken together represent a type with a defined contract for interaction with other types. ... A "Type 1" JDBC driver is a bridge to an ODBC driver which in turn interacts with the data store. ...
    (comp.lang.java.programmer)

Loading