Re: A text from a book which must be wrong(virtual, abstract metod)
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Sun, 25 Nov 2007 18:45:38 -0000
Tony Johansson <johansson.andersson@xxxxxxxxx> wrote:
I'm reading in a book about C# and here is something that sound strange.
"You can override a virtual method (or accessor) with an abstract method (or
abstract accessor) in a derived class.Any classes derived from this abstract
class must override these abstract methods and provide new implamantations
for them to become non-abstract."
What override a virtual method (or accessor) with an abstract method ??
This must be wrong??
It's easy enough to show that it's correct:
public class Base
{
public virtual void Foo()
{
}
}
public abstract class Derived : Base
{
public abstract override void Foo();
}
Basically it's saying, "Derived is rejecting the implementation of Foo
in Base - it's not optional to override it in classes derived from
Derived, you *have* to override it."
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
.
- References:
- A text from a book which must be wrong(virtual, abstract metod)
- From: Tony Johansson
- A text from a book which must be wrong(virtual, abstract metod)
- Prev by Date: Re: A text from a book which must be wrong(virtual, abstract metod)
- Next by Date: XML attributes or node ?
- Previous by thread: Re: A text from a book which must be wrong(virtual, abstract metod)
- Next by thread: XML attributes or node ?
- Index(es):
Relevant Pages
|