Hi.
You can have such ID if you will use generics:
{$mode Delphi}
type
TBase = class
public
function AndThis: T;
end;
function TBase.AndThis: T;
begin
result := self as T;
end;
type
TMyClass = class;
TMyClass = class (TBase)
end;
var
c: TMyClass;
begin
c := TMyClass.Creat
> On Mar 24, 2020, at 8:39 PM, Michal Wallace via fpc-pascal
> wrote:
>
> Hi Ryan,
>
> It's possible. Just change your declaration of `c`:
>
> var c: TBase;
>
> It still prints TMyClass at the end.
>
> Of course, you're only going to have access to methods that are declared in
> TBase.
>
Hi Ryan,
It's possible. Just change your declaration of `c`:
var c: TBase;
It still prints TMyClass at the end.
Of course, you're only going to have access to methods that are declared in
TBase.
You can also approach this sort of thing with interfaces...
-Michal ( http://tangentstorm.com/ )
Free Pascal - General mailing list wrote
> Is it possible to achieve this dynamically without resorting to type
> casting? It feels like classes should have a builtin type for each class,
> like TClassType, which similar to TObject.ClassType but is a compile time
> type.
I didn't think enough befo
Is it possible to achieve this dynamically without resorting to type casting?
It feels like classes should have a builtin type for each class, like
TClassType, which similar to TObject.ClassType but is a compile time type.
=
{$mode objfpc}
program test;
type
TBase = class
// TCl