Tuesday, June 29, 2010

Different Between Abstract Method And Virtual Method

Abstract method vs Virtual methods

Abstract method: When a class contains an abstract method, that class must be declared as abstract. The abstract method has no implementation and thus, classes that derive from that abstract class, must provide an implementation for this abstract method.

A subclass which derives from an abstract class and fails to implement abstract methods will fail to compile.

Virtual method: A class can have a virtual method. The virtual method has an implementation. When you inherit from a class that has a virtual method, you can override the virtual method and provide additional logic, or replace the logic with your own implementation.

Virtual methods allow subclasses to provide their own implementation of that method using the override keyword.

A member defined as virtual must be implemented in the base class, but may be optionally overridden in the derived lass if different behavior is required.

Sample Code Download : Learn_Abstract_Vs_Virtual.zip

No comments:

Image Understanding (IU)

Throughout these years, the growth of digital media collections has been accelerating, particularly in still images. These artifacts repre...