Class templates can be localized. The following is an example:
Template <typename T1, typename T2>
Class myclass {
...
}
The following local features are available:
// Localized features: the two template parameters have the same type
Template <typename T>
Class myclass <t, t> {
......
}
// Localized features: the type of the second template parameter is int.
Template <typename T>
Class myclass <t, int> {
...
}
// Localized features: both template parameters are pointer type
Template <typename T1, typename T2>
Class myclass <t1 *, T2 *> {
...
}
The following example shows the template used by various declarations:
Myclass <int, float> MIF; // use myclass <T1, T2>
Myclass <float, float> MFF; // use myclass <t, t>
Myclass <folat, int> MFI; // use myclass <t, int>
Myclass <int *, float *> MP; // use myclass <t1 *, T2 *>
If multiple local creden match a declaration to the same extent, it is called a declaration with two meanings:
Myclass <int, int> m; // error: Similarly, Chen de matches myclass <t, t> and myclass <t, int>
Myclass <int *, int *> m; // error: Match myclass <t, t> and myclass <t1 *, T2 *> to the same extent.