The following program compiles and gives output as expected, but if the lines that call the class destructor are uncommented it fails to compile with the error "identifier idents no member "Finalise"

program classConstructor;

{$mode objfpc}

uses Classes;

type

 TXClass = class
            class var int1: integer;
            class constructor Init;
            class destructor Finalise;
           end;

class constructor TXClass.Init;
begin
  int1:=-1;
end;

class destructor TXClass.Finalise;
begin
  int1:=0;
  writeln('TXClass.Finalise; int1 is ',int1);
end;

var x: TXClass;

begin
  x:= TXClass.Create;
  WriteLn('cc.int1 is ', x.int1);
//  TXClass.Finalise;
//  x.Finalise;
  x.Free;
  TXClass.int1:=1;
  WriteLn('TXClass.int1 is ', TXClass.int1);
  ReadLn;
end.

Am I not understanding how to use a class destructor, or is this a bug?

Howard
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to