Use the Features window to change the features of a constructor,
including its arguments and initialization code. Double-click the
constructor in the IBM® Rational® Rhapsody® browser
to open its Features window.
About this task
On this General tab,
you define the general features for a constructor through the various
controls on the tab. Notice that the signature for the constructor
is displayed at the top of the General tab
of the Features window.
- In theName field you specify
the name of the constructor. The default name is the name of the class
it creates. To enter a detailed description of the constructor, use
the Description tab.
- If the Name field is inaccessible,
click the L button to open the Name and Label
window to change the name, if any.
- In the Stereotype list you
specify the stereotype of the attribute, if any.
- To select from a list of current stereotypes in
the project, click the Select Stereotype button
.
- To sort the order of the selected stereotypes,
click the Change Stereotype Order button
. Note: The COM stereotypes are constructive;
that is, they affect code generation.
- In the Visibility list you
specify the visibility of the reception (Public, Protected,
or Private), if available. The default value is Public.
- In the Initializer field
you enter code if you want to initialize class attributes or super
classes in the constructor initializer. To access the text editor,
click the Ellipses button
.
For example,
to initialize a class attribute called a to 5,
type the following code: a(5)
Note: In C++, this assignment is generated
into the following code in the class implementation file to initialize
the data member in the constructor initializer rather than in the
constructor body:
//-------------------------------------------------------
// A.cpp
//-------------------------------------------------------
A::A() : a(5) {
//#[operation A()
//#]
};
Note: You must initialize
const data
members in the constructor initializer rather than in the constructor
body.