Abstract type: Difference between revisions
→{{header|PascalABC.NET}}
Alextretyak (talk | contribs) m (→{{header|11l}}: Void) |
|||
(One intermediate revision by the same user not shown) | |||
Line 2,554:
See [[#Delphi | Delphi]]
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
type
MyAbstract = abstract class
public
procedure Proc1; abstract;
procedure Proc2;
begin
end;
end;
MyClass = class(MyAbstract)
public
procedure Proc1; override;
begin
end;
end;
begin
var a := new MyClass;
a.Proc1;
end.
</syntaxhighlight>
Abstract method is a virtual method. You must overload it in a subclass using an override modifier.
It is also possible to define an interface and class, implementing this interface:
<syntaxhighlight lang="delphi">
type
IMyInterface = interface
procedure Proc1;
procedure Proc2;
end;
MyClass = class(IMyInterface)
public
procedure Proc1;
begin
Print(1);
end;
procedure Proc2;
begin
Print(2);
end;
end;
begin
var a: IMyInterface := new MyClass;
a.Proc1;
a.Proc2;
end.
</syntaxhighlight>
=={{header|Perl}}==
|