ibm Rational Rhapsody 7.5 — Creating a template class

Classes and types Template classes and generic classes Rational Rhapsody allows you to include generic design elements in your models. Specifically, you can: Љ Create and use template classes (C++) Љ Create and use generic classes (Java) Љ Create template functions (C++) Љ Create generic methods (Java) The terminology used for these concepts differs slightly between C++ and Java. In this section, we will use the UML terms template class and template operation to represent the generic elements in both C++ and Java. In general, the procedures described in this section apply to both C++ and Java. Where there are language-dependent differences, these differences are noted.

Creating a template class You can use a class to create a template class. In addition, some template parameters can be specified as specific types and a specialized function to create a specialization or new class/ function with content that is unrelated to the original template. Note that you can use the DiffMerge tool to locate and merge template information. To create a class template: 1. Double-click the class in the Rational Rhapsody browser to open its Features window. 2. On the General tab, in the Class Type area, select the Template radio button. Notice that the Template Parameters tab displays. 3. On the Template Parameters tab, click . 4.

Type a name to replace the default name that Rational Rhapsody creates as . For guidelines for these names, see Template limitations . 122 User Guide