For parts (attributes and roles) it is possible to set a Default Value not only on the object itself, but also on redefinitions of the object. Where this has been done, the C++ generator will produce code which initializes the redefined part. It does this by adding various classes and constructors or modifying constructors of the classes which contain the redefined parts.
An attribute in the following example, has had a Default Value set. All other Default Value properties have been set on redefinitions.
Most parts shown in the composite structure diagram have been redefined by the setting of a Default Value. However, Class4.c3a has been redefined by the addition of m_Int which is not a member of Class3 (the type of Class4.c3a.) Similarly, Class4.c3a.c2b (typed by Class2) has been redefined by the addition of m_Long.
The approach taken by the generator is that the constructor of any class used as a part with in-context default values at some depth within it will be generated with parameters which are used in the initializer list. The constructor of any class not used as a part but which contains parts as described above will be generated without parameters and the in-context default values will be used in the initializer list. If the constructor has been modelled then it will be modified in accordance with the above. If no constructor has been modelled then one will be fabricated for this purpose. Furthermore, parts which have been redefined by the addition of parts which do not exist in the part type (e.g. Class4.c3a & Class4.c3a.c2b) will have classes fabricated which do contain the additional parts and constructors required for initialization.
So, in this example, the modelled classes will have the following constructors:
Class1::Class1( const int Class1_m_Int, const float Class1_m_Float ): m_Float(Class1_m_Float), m_Int(Class1_m_Int) { } Class2::Class2( const float Class2_c1b_m_Float, const float Class2_c1a_m_Float, const int Class2_c1a_m_Int const int Class2_c1b_m_Int ):