| 发表于:2007-02-27 00:33:13 楼主 |
由于最近这段日子感到bcb越来越困难,所以打算转型成delphi,正在学习op语法 下面这段代码编译正常通过,但是会出错,望前辈指点 implementation {$r *.dfm} type thuman = class {没有指定父类应该是从tobject派生吧} public sex : boolean; age:integer; function retire(intage:integer):boolean; end; function thuman.retire(intage:integer):boolean; begin if intage > = 60 then result := true else result := false; end; procedure tform1.button1click(sender: tobject); var curhuman1:thuman; begin curhuman1.create( );{关键位置,如果我不在这里使用create程序编译完执行下一句的时候会出错,意思可能是没有初始化} curhuman1.age := strtoint(edit1.text); if curhuman1.retire(curhuman1.age) then label2.caption:= '已经退休 ' else label2.caption:= '正在工作 '; curhuman1.free();{关键位置,这句我无论是注释掉还是让其运行,程序最后都会抛开异常, windows显示程序异常关闭} end; |
|
|
|
|