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
Subscribe to:
Post Comments (Atom)
Image Understanding (IU)
Throughout these years, the growth of digital media collections has been accelerating, particularly in still images. These artifacts repre...
-
Year: 2001 Programming Language: Java Source Code: Email the author: ahyeek@gmail.com Application For Test: ahyeek@gmail.com Related Doc...
-
Year: 2004 - 2005 Programming Language: OpenGL, C, C++, Titanium Award: Gold medal award of the Invention Exhibition of New Invention,...
-
Year: 2002 Programming Language: MS. Visual C++ Ver 6.0 Source Code : Core code shared here Application For Test: Download Full Working ...
No comments:
Post a Comment