ne***********@gmail.com wrote:
Hi, I read this in a book about the Xml classes in c#:
"These classes are abstract and therefore must be extended."
I just wanted to know what this statement means. I know it is not in
context, but the author gave it in such a matter that it appears
experience folks will know what it means to say a class is abstract
and extended.
Thanks.
An abstract baseclass might contain some code (methods), but at least
has one "abstract" method. This is not a "real" method at all (it contains no
code), but rather some sort of "placeholder". By using an abstract method
you declare that all derived classes (classes that use this abstract class
as a baseclass) also have this method. If those derived classes are not
abstract themselves, they *must* provide code ("implement") these
abstract methods.
Why have methods that you can't use?
You can use that abstract type as a parameter type for some method
(this method might be in the same baseclass, or somewhere else).
When you call that method you have to specify some "real" object, that
derives from the (abstract) baseclass. Because the method (-signature)
is defined in that baseclass, the method (or rather compiler) knows it can
use it. How it is implemented is not important.
Hans Kesting