Results 1 to 3 of 3

Thread: abstract/base class Q's

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    abstract/base class Q's

    I'm kind of in a different and wierd mindset, so I apologise.

    What is the point on having abstract/inheritence? Example, we can have a base class called "vehicle", has methods like "drive()" "stop()" etc.... and classes "Car", "Truck", "Van", "Bus" can derrive from base class "vehicle". Thats all very well, but really what would be the point in that?

    why should we also sometimes call a base method? Would that only happen if we override a method which has been declared as a virtual method in the base class?

    Sorry for the silly Q, im just soaked up in something and perhaps thinking way too hard into it.

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: abstract/base class Q's

    The point of an abstract class is that you ensure that all derived types can do a certain thing but you don't care how they do it. An abstract base class is generally like a combination of a regular base class and an interface. You get the ability to implement some members like a regular base class, but you also get the ability to force each derived class to implement certain behaviour to ensure a standard interface to possibly disparate functionality.

    Yes, you call a base method when you still wnat to invoke the "standard" beahviour but also add some custom behaviour of your own. An example is overriding the OnPaint method in a control. You add some code of your own to do some custom drawing but you also invoke the base method so that the control's Paint event is raised.
    Last edited by jmcilhinney; Sep 18th, 2007 at 07:28 PM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: abstract/base class Q's

    thanks, much appreciated.

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width