在Lazarus中使用以下类代码我在writeln上得到以下错误(woman.name,'已经诞生'); line:" Project My Application引发了异常类'外部SIGSEV'。其他pascal代码似乎工作正常
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.
答案 0 :(得分:3)
您需要以这种方式实例化对象:
woman := human.born('Tracy');