[fpc-devel] Hom to initialize an object (old style object, not TObject)
Martin
lazarus at mfriebe.de
Fri Nov 1 15:59:27 CET 2013
If I have the code as shown at the end of the mail, i get
project1.lpr(6,9) Warning: Function result variable does not seem to
initialized
but how can I initialize it?
**** Unit1
unit Unit1; {$mode objfpc}{$H+}
interface
uses Classes, SysUtils;
type
TBar = object
private
a: integer;
public
procedure Init;
end;
implementation
procedure TBar.Init;
begin
a := 0;
end;
end.
**** main program
program Project1;
uses Unit1;
function Foo: TBar;
begin
Result.Init;
end;
begin
Foo;
end.
More information about the fpc-devel
mailing list