Show: Object Pascal C++
Display Preferences

Creating Properties with the C++ Class Explorer

From Appmethod Topics
Jump to: navigation, search

Go Up to C++ Class Explorer Topics

This procedure illustrates how to create a property that is associated with a selected class or interface using the C++ Class Explorer.

To create a property in the C++ Class Explorer

  1. Do either of the following:
    • Open the C++ Class Explorer as described here.
    • If the C++ Class Explorer is already running, return to the C++ Class Explorer by clicking the C++ Class Explorer tab at the top of the window.
  2. In the Type List pane, select the class or interface to which you want to add a property.
  3. Do either of the following:
    • Right-click the class or interface, and select Add property from the context menu.
    • Click the Add a new property to this class toolbar button ClExplAddProperty.bmp.
  4. On the Add Property To <name> dialog box, enter a name for the property in the Name box.
  5. In Type, either enter the data type of the property you are adding, or select a data type from the dropdown list.
  1. In Read, select one of the following read function options:

    • Existing field/method allows you to specify an existing class member (typically a field) that will provide the read value for this property.
    • Create getter method creates a stub for the getter method in the .cpp file of the managed unit. Also creates a declaration for the read function in the .h file. The default name used is Get<propertyname>.
    • Write-only property specifies that the property value cannot be read; it can only be set.

    You can also choose to create a read/get function later in the Code Editor.

  2. In Write, select one of the following write function options:

    • Existing field/method allows you to specify an existing class member that will be used to set the value of this property.
    • Create setter method creates a stub for the setter method in the .cpp file of the managed unit. Also creates a declaration for the write function in the .h file. The default name used is Set<propertyname>.
    • Read-only property specifies that the property value cannot be set; it can only be read.

    You can also choose to create a write/set function later in the Code Editor.

  3. Click Add. The property is added to the user declarations in the .h file for the unit containing the declaration of the class or interface. Stub implementations of any getter or setter methods are created in the unit's .cpp file.

See Also

Personal tools
In other languages