Creating a Method - Example
Go Up to Delphi Class Explorer Topics
Assume that you want to insert a privately declared function named Test into a class named TTestClass.
The new function shall have two arguments i and j, both of the integer type and it should return a boolean value.
To add such a function you should specify the following options in the Add Method dialog box:
- Type Test in Method name.
- Select the TTestClass class name in the Add to class combo box.
- Type I : Integer; J : Integer in the Arguments field.
- Check the function option in the Method type group, then select Boolean in the Return type combo box.
- Check the private option in the Visibility group.
- Click OK. The Delphi Class Explorer adds the following code for the function with the specified options:
- Into the declaration of the TTestClass class: TTestClass = class .... private function Test(I : Integer; J : Integer): boolean; .... end; .
- Into the implementation section of the unit file.