Virtual
Deutsch · English
Back to Reserved words.
The modifier virtual:
- belongs to object-oriented programming;
- describes a virtual method.
A virtual method must also be implemented (programmed) in the class in which it was declared.
A virtual method can be overwritten in a derived class with the reserved word override.
If a virtual method is to be hidden, the class must be covered with the reserved word Reintroduce.
Example:
Type
TBody = class
private
dblHeight : double;
public
function volume : double; virtual; // This method can be in one of this class
// derived class can be hidden or overwritten
function surfaceArea double; virtual; // This method must be in one of this class
// derived class can be hidden or overwritten
end;From the Free Pascal wiki, page "Virtual", as it stood on 2020-03-03 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
