關於函數傳遞參考Out |
答題得分者是:huwk
|
fantasy
一般會員 發表:10 回覆:9 積分:3 註冊:2003-11-27 發送簡訊給我 |
小妹想問一個問題關於 傳遞參考 經過小妹測試結果
傳址的話,可以把找出值全部找出來,但是傳參考卻是怪怪的
想請問各各大大能指導一下,或是提供相關的文章,謝謝
type tst=record lName:String; fName:String; age:integer; end; procedure pout(out student:tst); begin Form1.Edit1.Text:=student.lName; Form1.Edit2.Text:=student.fName; Form1.Edit3.Text:=inttostr(student.age); end; procedure pptr(var pstudent:tst); begin Form1.Edit1.Text:=pstudent.lName; Form1.Edit2.Text:=pstudent.fName; Form1.Edit3.Text:=inttostr(pstudent.age); end; procedure TForm1.Button1Click(Sender: TObject); var me:tst; begin me.lName:='fanny'; me.fName:='Fantasy'; me.age:=22; pptr(me); end; |
huwk
資深會員 發表:26 回覆:340 積分:323 註冊:2002-04-03 發送簡訊給我 |
參考HELP即可以很清楚
An out parameter, like a variable parameter, is passed by reference. With an out parameter, however, the initial value of the referenced variable is discarded by the routine it is passed to. The out parameter is for output only; that is, it tells the function or procedure where to store output, but doesn急 provide any input. 1.他只不接受任何傳入的初值
2.在FUNCTION內宣的值會改變外面的值 SO.通常OUT只適合完全在FUNCTION內初始化的動作
------
熊的學習 http://huwk.blogspot.com |
fantasy
一般會員 發表:10 回覆:9 積分:3 註冊:2003-11-27 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |