- 好友
- 0
- 帖子
- 124731
- 積分
- 124889
- 最後登錄
- 2019-2-28
- 在線時間
- 0 小時
- 好友
- 0
- 帖子
- 124731
- 積分
- 124889
- 最後登錄
- 2019-2-28
- 在線時間
- 0 小時
|
本人已把 Unit1 链接 Unit2,Unit2 裡有两个函数,而Unit1 有一个自身函数和三个控件。
1 - 关於Overload的问题:
1.1. 如果这样的情况下在Unit2 用Overload 指令对吗?
1.2. 有什麼负面效果?
1.3. 以你的建议,你会怎样以最好的方法使用Overload?
2 - 关於Result:
2.1. Unit2 裡的『function TCon.Runtest: string;』和『function TCon.Runtest(Value: string): string;』
的Result,它们有什麼分别??
2.2. 每个Function 裡是不是都附带着Result(回函值)?
2.3. Result := Value; <--这是什麼,它是什麼时候才出现?
2.4. while j <= 5 do
begin
Result := Result + ' ' + IntToStr(j); <--这个 Result(回函值)是不是属於 while?
3 - 关於Unit1 的Button3 自身函数:
3.1. 我要怎样在裡面加入 Constructor 和 Destructor?『请给例子』
3.2. Create 是属於 Constructor 的值吗?
3.3. Free 是属於 Destructor 的值吗?
3.4. 如果不用 Constructor 和 Destructor 会有什麼负面效果出现?<div class="blockcode"><span class="headactions" onclick="copycode($('code0'));">複製內容到剪貼板</span><h5>代碼:</h5><code id="code0">unit Unit2;
interface
uses
SysUtils;
type
TCon = class
private
i, j : Integer;
public
function Runtest : string; overload;
function Runtest(Value : string) : string; overload;
end;
implementation
{ TCon }
function TCon.Runtest: string;
begin
i := 1;
while i <= 4 do
begin
j := i;
while j <= 5 do
begin
Result := Result + ' ' + IntToStr(j);
Inc(j);
end;
Inc(i);
end;
end;
function TCon.Runtest(Value: string): string;
begin
Result := Value;
i := 1;
while i <= 3 do
begin
j := i;
while j <= 5 do
begin
Result := Result + ' ' + IntToStr(j);
Inc(j);
end;
Inc(i);
end;
end;
end.</code> |
|