Re: diff between virtual and abstract?
Tech-Archive recommends: Speed Up your PC by fixing your registry
If a subclass *needs* to override a member (i.e. you can't specify a
meaningful body in the base class, as it can't be defined), then it should
be abstract in the base-class; if you just want to give the subclass the
*ability* to override a method (if they want) then it should be virtual. Any
abstract member forces the entire class to be abstract, which also means you
can't create actuall instances of the base class, but you can of the
superclass.
Does that make sense?
Marc
.
Relevant Pages
- Re: What can I store in LPARAM
... I'm not saying you're wrong, but with my call back up to the base class, ... may choose to override it completely, or by adding code before or after ... comments below regarding leaf. ... This means that a subclass can't change the method body behind ... (microsoft.public.vc.mfc) - Re: Subclassing controls
... Suppose their is a property called Bold that I can't override. ... own base class version or will it see my new implementation of it? ... At any time, from within the definition of the subclass, you may ... (microsoft.public.dotnet.languages.csharp) - Re: virtual and override methods
... If C didn't have an override, ... > inherits the virtual method from A? ... > make calls to overridden members in the base class by prefacing the ... > the other subclass uses this ... (microsoft.public.dotnet.languages.csharp) - C# example
... When a member is overridden, the new member is called in place of the member ... if an instance of an inherited class is cast to its base class ... I created 2 classes and would like to call the "method" to depict the para ... public override string method() ... (microsoft.public.dotnet.languages.csharp) - Re: The Override Problem
... mistake and you don't override a method that you should actually override. ... If you intend to have every subclass invoke super.method1, then it would be better to have method1be abstract in the superclass and ask every subclass to invoke super.method2, where method2is protected. ... Or actually, what would be better, would be to make method1final in the base class, have it invoke method2and make method2abstract and protected. ... (comp.lang.java.programmer) |
|