Home > Back-end >  How to define how to define a custom types of constant? Generally defined types of set? What can you
How to define how to define a custom types of constant? Generally defined types of set? What can you

Time:11-12

The problem is:
Const
R: TRect=(Left: 0; Top: 0; Right: 60; Bottom: 60);
You can define a rectangular;

But how do I custom types set to constant
Type
TCalPoint=class
Public
X: Integer;
Y: Integer;
Value: Single;
Public
Procedure Cal.
end;

CodePudding user response:

Trect structure, can't do that class should be a const

CodePudding user response:

Because of Delphi object is a reference type, not a value type, so you can only:
Const
{$J +}
C: TCalPoint=nil;
{$J -}

CodePudding user response:

Can be used to record or object type to replace

CodePudding user response:

Later versions of Delphi7, I in Delphi XE5 definition:
 
Type
TMyClass=class
Public
Const R: TRect=(Left: 0; Top: 0; Right: 60; Bottom: 60);
end;

CodePudding user response:

TRect is structure its memory is on the stack, the class is a class that the object is the memory on the heap (programmer yourself managing memory)
  • Related