2
votes

Uing the following class code in Lazarus I get the following error on the writeln(woman.name, 'has been born'); line: "Project My Application raised exception class 'External SIGSEV'. Other pascal code seems to work ok

program project1;
uses wincrt;

type human = class
   private
      health : integer;
   public
      name : string;
      constructor born(n: string);
end;

constructor human.born(n: string);
begin
  name := n;
  health := 100;
end;

var
  woman : human;

begin
  woman.born('Tracy');
  writeln(woman.name, 'has been born');
end.
1

1 Answers

3
votes

You need to instantiate object this way:

woman := human.born('Tracy');