ILE C/C++ Programmer's Guide

Explicit Instantiations

An explicit instantiation of a class forces the definition a class specialization without creating any object of the class. It implies the instantiation of all members of the class that have not already been explicitly specialized. If you do not require all class members in your program, you can explicitly instantiate only those indidvidual members that the program requires.

For more information about explicit instantiations, see the Websphere Development Studio: ILE C/C++ Language Reference. In the index, look up "templates", and then the subheading "instantiations", "explicit".

In Figure 321:

Note:
If you know all instances of the Stack class that are used in your program, you can define all of the instances in a single compilation unit.

Figure 321. Example of All Instances of a Class Defined in a Single Compilation Unit



#include "stack.h"
#include "stack.c"
#include "myclass.h" // Definition of "myClass" class
template class Stack<int,20>;
template class Stack<myClass,100>;


[ Top of Page | Previous Page | Next Page | Table of Contents ]