How sub classes of abstract classes interact?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jivesh

    How sub classes of abstract classes interact?

    any subclass of an abstract class must either implement all of the abstract methods in the superclass or be iteself declared abstract why?
    Last edited by Dormilich; Nov 22 '10, 06:37 AM. Reason: please use a meaningful title
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    Basically, an abstract class is a sort of template. In it, it says "any class that uses me will have the following functions, variables, etc.". Everything accessing a subclass of this will therefore assume, that these functions, variables, etc. exist - which will only be the case, if you implemented them.

    Of course, you can have another abstract class, that has all stuff that that other one had plus something more - that would be ok without having to implement the functions, because it's still just a "template".

    There is also something called an "Interface" , which solves similar problems. To read up on both Interfaces and abstract classes, I'd recommend this article.

    Greetings,
    Nepomuk

    Comment

    Working...