Re: Abstract classes and methods
Re: Abstract classes and methods
- Subject: Re: Abstract classes and methods
- From: Chris Gehlker <email@hidden>
- Date: Wed, 29 Aug 2001 07:14:01 -0700
On 8/29/01 3:24 AM, "Smith, Bradley" <email@hidden> wrote:
You've got the terms backward here Bradley. At least according to Stroustrup
and Meyers a "virtual" class has one or more pure virtual functions.
An abstract class has a virtual, not pure virtual, destructor. All virtual
classes are abstract but the converse is not true.
A concrete class has a destructor that is not declared virtual. It may be
virtual by virtue of inheritance but that's not important.
Note that a class can be abstract if the author thinks it is a candidate for
derivation. This does not mean that she intends any method but the
destructor to be overridden. She may think that descendents should only add
instances and methods.
>
This could get messy but here goes anyway: -
>
>
> So it might be
>
> helpful to review the definitions.
>
>
>
> Virtual - Can't be instantiated which is enforced by the language.
>
>
Actually a virtual method can be invoked, unless it is also abstract (pure
>
in C++).
>
A virtual method is one which is likely to be overridden by subclasses.
>
>
> Abstract - Might be a good candidate for sub classing. May or
>
> may not be
>
> virtual. Indicated by declaring the destructor virtual.
>
>
Again no. Any class with at least one abstract method *must* be subclassed.
>
An abstract method is always virtual (in C++)
>
>
> Concrete - Not intended to be sub classed. Indicated by not
>
> declaring the
>
> destructor virtual.
>
>
True. Any class with at least one virtual method should also have a virtual
>
destructor.
>
>
Brad
>
_______________________________________________
>
cocoa-dev mailing list
>
email@hidden
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
--
Cogito Ergo Spud. - I think therefore I yam.