Add Property (C++)

From RAD Studio
Jump to: navigation, search

Go Up to View Menu


Adds a property to a class in the C++ Class Explorer.

On the C++ Class Explorer Window, invoke the Add Property dialog box from either:

  • The Add a new property to this class ClExplAddProperty.png toolbar button
  • The context menu command Add property.

Note: The Add Property context menu command and the Add a new property to this class ClExplAddProperty.png toolbar button are enabled only for elements that are declared in a C++ managed unit. To create a C++ unit, choose either:

  • File > New > Unit - C++Builder
  • File > New > Form - C++Builder

C++ managed units differ from ordinary C++ source files in that the header (.h) and implementation (.cpp) files are grouped together. For a C++ managed unit, the Code Editor displays a tab for the .cpp file and a tab for the .h file along the bottom of the window.

You cannot add fields, methods, or properties to VCL or FireMonkey elements using the C++ Class Explorer.


Item Description

Name

Specifies the name of the property.

Type

Specifies the type of the property. You can select one of the predefined types from the combo box or you can enter another existing type.

Visibility

Specifies the visibility of the property being created. Select from:

Read options

  • Existing field/method allows you to specify an existing class member (typically a field) that will provide the read value for this property. Enter a class name or select one from the dropdown list.
  • 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 for the getter method is Get<propertyname>.
  • Write-only property specifies that the property value cannot be read; it can only be set.

Write options

  • Existing field/method allows you to specify an existing class member that will be used to set the value of this property. Enter a field/method name, or select one from the dropdown list.
  • 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 for the setter method is Set<propertyname>.
  • Read-only property specifies that the property value cannot be set; it can only be read.



See Also