Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-05

Constant object

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Müller

How can I declare a constant object?

var
  MyTest: TObject;
begin
  MyTest := TObject.Create;
end.

works (for sure).

How can I declare 'const'?

Thanks

Michael

Geno Roupsky
to Michael Müller

I guess you're refering to the old tp days. If so you should be able to acheive constant object like that:

type
  TCObject = object
    P1: Double;
  end;
var
  MyCObject: TCObject;
begin
  MyCObject.P1 := 0;
end.

This code should world although I haven't tested it. But there is no easy(without some nasty hacking) way to have a class instance as a constant object.

2006/5/2, Michael Müller :

Show quoted text 20 lines
How can I declare a constant object? var MyTest: TObject; begin MyTest := TObject.Create; end. works (for sure). How can I declare 'const'? Thanks Michael _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Geno Roupsky