Delphi7 (第一天:类的编写)
万恶的delphi,写的超慢。。。。。
万恶的pascal,万恶的begin。。end
我叼!一点都不人性化的设计。我去。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
program Project1; {$APPTYPE CONSOLE} uses SysUtils, Unit1 in 'Pas\Unit1.pas'; var p:Person; begin p:= Person.Create; p.setName('Delphi作者'); p.setAge(0); p.setSex('变态'); p.speak; Readln; end.
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
unit Unit1; interface type Person=class private name:string; age:Integer; sex:string; public procedure setName(name:string); function getName:string; procedure setAge(age:Integer); function getAge:Integer; procedure setSex(sex:string); function getSex:string; procedure speak; end; implementation procedure Person.setName(name:string); begin Self.name:=name; end; function Person.getName:string; begin Result:= Self.name; end; procedure Person. setAge(age:Integer); begin Self.age:=age; end; function Person.getAge:Integer; begin Result:=Self.age; end; procedure Person.setSex(sex:string); begin Self.sex:=sex; end; function Person.getSex:string; begin Result:=Self.sex; end; procedure person.speak; begin Writeln('我操,写的真慢'); end; end.
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步