上一页 1 ··· 181 182 183 184 185 186 187 188 189 ··· 215 下一页
摘要: //类中的方法重载首先具备前面说过的重载相关的所有特点, 如: TMyClass = class(TObject) function Fun(s: string): string; overload; function Fun(i: Integer): Integer; overload; function Fun(x,y: Integer): string; overload; ... 阅读全文
posted @ 2008-01-16 19:53 万一 阅读(6662) 评论(2) 推荐(0)
摘要: //静态方法是默认的, 如果不是虚方法或纯虚方法, 那它就是一个静态方法. //类方法就是通过类名就可以访问的方法 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TFo... 阅读全文
posted @ 2008-01-16 17:07 万一 阅读(11589) 评论(10) 推荐(1)
摘要: //下面说的数据成员不仅仅指方法 TMyClass = class(TObject) function Fun1: string; {公共区域的数据成员在默认状态下会归于 published 区} //所谓默认状态就是编译指令为{$M+}, 如果是{$M-}这些数据成员会归于 public 区 private function Fun2: string; {private 区的数据... 阅读全文
posted @ 2008-01-16 15:52 万一 阅读(5257) 评论(4) 推荐(0)
摘要: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) end; TBass = class function Fun1(x,... 阅读全文
posted @ 2008-01-16 15:51 万一 阅读(4020) 评论(4) 推荐(0)
摘要: //标准的覆盖是这样的 TBass = class procedure Proc; virtual; {或用 dynamic} end; TChild = class(TBass) procedure Proc; override; end; //以下几种情况属于重定义, 其中例 3-5 还会有编译提示 {例1} TBass = class procedure Proc; e... 阅读全文
posted @ 2008-01-16 13:14 万一 阅读(4630) 评论(3) 推荐(0)
摘要: 方法来到类中, 以前的特点基本都在; 因为类一般是存在于一个继承链中, 所以就有了一些新的概念, 譬如: 继承、覆盖; 也有了很多新名称, 譬如: 静态方法、虚方法、动态方法、抽象方法、类方法、消息方法. 先从虚方法与动态方法开始吧 //下面的类中就定义了两个虚方法(virtual)、两个动态方法(dynamic) TMyClass = class procedure Proc1(x,y:... 阅读全文
posted @ 2008-01-15 16:07 万一 阅读(5693) 评论(2) 推荐(0)
摘要: {给这个函数可以赋常数变量} function Fun1(x,y: Integer): Integer; begin Result := x + y; end; {这个函数不能赋予常数变量} function Fun2(var x,y: Integer): Integer; begin Result := x + y; end; {测试} procedure TForm1.Butt... 阅读全文
posted @ 2008-01-15 15:52 万一 阅读(3961) 评论(1) 推荐(1)
摘要: //上面一个例子不能说明递归函数的本质, 直接来个实用的函数吧, 刚好要用. unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) ... 阅读全文
posted @ 2008-01-15 15:45 万一 阅读(5713) 评论(2) 推荐(0)
摘要: //所谓递归函数, 就是自己调用自己的函数, 先来个简单的例子: {递归调用的简单示例} procedure alert(i: Integer = 1); begin ShowMessage(IntToStr(i)); {这是方法的功能} Inc(i); if i 阅读全文
posted @ 2008-01-15 11:57 万一 阅读(5119) 评论(2) 推荐(0)
摘要: //把一个方法当作另一个方法的参数, 就是回调方法, 大家习惯称作回调函数 type TFunType = function(i: Integer): Integer; {声明一个方法类型} function MyFun(i: Integer): Integer; {建立类型兼容的函数} begin Result := i*2; end; {把函数当作参数, 再定义一... 阅读全文
posted @ 2008-01-15 11:37 万一 阅读(9119) 评论(7) 推荐(0)
上一页 1 ··· 181 182 183 184 185 186 187 188 189 ··· 215 下一页