Creating Properties with the C++ Class Explorer
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
- 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.
- In the Type List pane, select the class or interface to which you want to add a property.
- Do either of the following:
- On the Add Property To <name> dialog box, enter a name for the property in the Name box.
- In Type, either enter the data type of the property you are adding, or select a data type from the dropdown list.
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.
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.
- 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.