Creating constructors

Constructors are called when a class is instantiated.

Procedure

  1. In the model browser, right-click a class to open the pop-up menu.
  2. Select Add New > Constructor
    The Constructor Arguments window is displayed.
  3. Use the controls to add the arguments you want to use for the constructor.
  4. Click OK to close the Constructor Arguments window.
    The new constructor can now be seen beneath the class in the browser (in the Operations category).
  5. Double-click the new constructor to open the Features window.
  6. On the Implementation tab of the Features window, enter the body for the constructor.
  7. If you want to add initializer code, go to the General tab of the Features window and use the Initializer field.
    Note: You can also create a constructor by using the controls on the Operations tab of the Features window for a class, or by selecting the relevant option in the pop-up menu for classes that are displayed in a diagram.