馬上註冊  |  找回密碼

SAY討論區

查看: 342|回復: 3
打印 上一主題 下一主題

『急急,Delphi 功課』Overload,Constructor,Destructor(Delphi 高手請賜教!!) [複製鏈接]

好友
0
帖子
124731
積分
124889
最後登錄
2019-2-28
在線時間
0 小時
跳轉到指定樓層
樓主
發表於 2012-5-12 02:16:12 |只看該作者 |倒序瀏覽
本人已把 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 &lt;= 4 do
begin
  j := i;
  while j &lt;= 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 &lt;= 3 do
begin
  j := i;
  while j &lt;= 5 do
  begin
  Result := Result + ' ' + IntToStr(j);
  Inc(j);
  end;
Inc(i);
end;
end;
end.</code>
分享分享0 收藏收藏0 讚好讚好0 Unlike!Unlike!0 分享 傳送 邀請

好友
0
帖子
130341
積分
135748
最後登錄
2019-2-28
在線時間
0 小時
No.1回覆者
發表於 2012-5-12 03:20:42 |只看該作者
3q for 分享

好友
0
帖子
125069
積分
125120
最後登錄
2019-2-28
在線時間
9 小時
跟尾2
發表於 2012-5-14 05:44:59 |只看該作者
樓上的稍等啦

好友
0
帖子
124856
積分
124963
最後登錄
2019-2-28
在線時間
0 小時
跟尾3
發表於 2012-5-14 05:44:59 |只看該作者
不錯的東西  持續關注
您需要登錄後才可以回帖 登錄 | 馬上註冊 |

Archiver|手機版|SAY討論區

GMT+8, 2026-5-27 18:22 , Processed in 0.623290 second(s), 8 queries .

Powered by go2tutor.comDiscuz! X2

© 2026 Community Networks Limited

回頂部