Adding initialization code in the constructor body

To enter code for any initializations that you want to perform in the constructor body rather than in the constructor initializer, use the Implementation tab.

About this task

You can create and initialize objects participating in relationships within the body of a constructor. You can pass arguments to these objects if they have overloaded constructors using, for example:

new relatedClass(3)

This code in the body of the class constructor calls the constructor for the related class and passes it a value of 3. The related class must have a conversion constructor that accepts a parameter. The constructor of the related class then performs its initialization using the passed-in value.


Feedback