Note for explicit and special template:
I,
The specified template parameter list must be one-to-one. For example
A non-type value to replace a template parameter. However, if the template parameters have the default template parameters
Template parameters are optional:
Template <typename T>
Class types {
Public:
Typedef int I;
};
Template <typename T, typename u = typename types <t >:: I>
Class S;
Template <>
Class S <void> // OK
{
Public:
Void F ();
};
Template <>
Class S <char, char>; // OK
Template <>
Template <> class S <char, 0>; // error. You cannot use 0 to replace U.
Ii. Global Membership Specialization
# Include <iostream>
Using namespace STD;
Template <typename T>
Class outer {/1
Public:
Template <typename u>
Class inner
{
PRIVATE:
Static int count;
};
Static int code; // 4
Void print () const // 5
{
STD: cout <"generic" <Endl;
}
}
/* Code at 4 and print () at 5. Both common members have a peripheral class template. Therefore,
* Template <> prefix Description: A template real parameter set will be used later to globally optimize the template.
*/
Template <>
Int outer <void >:: code = 12;
Template <>
Void outer <void>: Print () const
{
STD: cout <"outer <void>" <Endl;
}
/* 1. the above definitions will be used to replace the generic definitions of class Outer <void> at 4 and 5; but the class Outer <void>
* Other members still default the template where the property is located at 1 by default.
* 2. After the preceding statement is provided, the outer <void> display feature cannot be provided again.
*/