Sign in Join
Wiki copytemporary

Programming Using Classes/ja: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Programming Using Classes/ja

OldNewLine
1+## Object Pascal でクラスを用いる
2+
3+クラスを使用するには、クラスメソッドを呼び出すか、クラスのインスタンスを作成してそのフィールド、プロパティ、メソッドを使用する。
4+
5+Object Pascalクラスのインスタンスは一般的に 「object」 と呼ばれるが、Object PascalのObjectsとは異なることに注意してすること。クラスのインスタンスを作成するには、そのコンストラクタの1つを呼び出す必要がある。コンストラクタはクラスのインスタンスを返す。返されたインスタンスを変数に割り当てて使用できるようにし、後で Free メソッドを使用してインスタンスを解放することを忘れないこと。TComponentの派生クラスは、コンストラクタで所有者を指定できる。その場合、所有者が解放されるとインスタンスも解放され、手動で Free を呼び出す必要はない。
6+
7+以下の例は、クラスを作成し、そのメソッドにアクセスするために使用できる構文を示しています:
8+
9+``` pascal
10+var
11+ MyStringList: TStringList;
12+begin
13+ MyStringList := TStringList.Create;
14+ try
15+ MyStringList.LoadFromFile('path_to_my_file.txt');
16+ // ...
17+ finally
18+ MyStringList.Free;
19+ end;
20+end;
21+```
22+
23+## 以下も参照のこと
24+
25+- [[Object Oriented Programming with Free Pascal and Lazarus/ja]]
26+
27+---
28+*From the Free Pascal wiki, page "Programming Using Classes/ja", as it stood on 2024-04-03 after a change by Ariben, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
29+Category: FPC
30+Category: Object-oriented development

Back to history