Wiki copymirror

This is a mirror of the wiki at pascal.chat. Editing, history and sign-in are there.

Virtual

Deutsch ยท English

Back to Reserved words.

The modifier virtual:

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:

pascal
 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.

Revision 1, last changed by WikiArchive .