User Tools

Site Tools


tutorial:class

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorial:class [2019/01/28 10:08]
admin
tutorial:class [2019/01/29 08:24] (current)
admin
Line 21: Line 21:
 |ไม่ระบุ| หมายถึง public |  ​ |ไม่ระบุ| หมายถึง public |  ​
  
 +\\
 +----
 =====การสร้าง Class===== =====การสร้าง Class=====
 การสร้าง Class อย่างง่าย มีรูปแบบดังนี้ การสร้าง Class อย่างง่าย มีรูปแบบดังนี้
Line 36: Line 38:
    end;    end;
  
-__**หมายเหตุ**__ - ในการสร้าง Class ทุกๆครั้งที่ไม่ได้ระบุว่าสืบทอดมาจาก Class ใด จะเป็นการสร้าง Class สืบทอดจาก TObject ซึ่งเป็น Class พื้นฐานของ FPC เสมอ+__**หมายเหตุ**__ - ในการสร้าง Class ทุกๆครั้งที่ไม่ได้ระบุว่าสืบทอดมาจาก Class ใด จะเป็นการสร้าง Class สืบทอดจาก TObject ซึ่งเป็น Class พื้นฐานของ FPC เสมอ ​\\ 
  
-=====Proerty===== +ตัวอย่างการสร้าง Class แบบละเอียด 
-คือ คุณสมบัติของ Object ประกอบไปด้วย Getter (คำสั่งหลัง read) และ Setter (คำสั่งหลัง write)\\ \\+<sxh delphi;>​ 
 +Type 
 +  TMyClass ​class(TObject) 
 +   ​private 
 +     ​FName:​string;​ 
 +     ​FValue:​integer; ​      
 +   ​protected 
 +     ​function GetIsOK:​boolean;​ 
 +   ​public 
 +     ​constructor create; 
 +     ​destructor destroy; override; 
 +     ​procedure DoSomeThing; ​         
 +   ​published 
 +     ​property Name:string read FName write FName; 
 +     ​property Value:​integer read FValue write FValue default 0;  
 +     ​property IsOK:​boolean read GetIsOK;  
 +   ​end;​ 
 +</​sxh>​ 
 +\\ 
 + 
 +---- 
 +=====Property===== 
 +คือ คุณสมบัติของ ​Class (หรือ ​Object) เช่น ความยาว ความกว้าง ตำแหน่ง เป็นต้น โครงสร้างของ property นั้นประกอบไปด้วย Getter (คำสั่งหลัง read) และ Setter (คำสั่งหลัง write)\\ \\
 เพื่อเป็นการอธิบายให้เห็นภาพ จะขอยกตัวอย่าง เพื่อเป็นการอธิบายให้เห็นภาพ จะขอยกตัวอย่าง
  
tutorial/class.1548644887.txt.gz · Last modified: 2019/01/28 10:08 by admin