template<>
class A{
//some class data
};
I have seen this kind of code many times.
what is the use of template<> in the ab
template<> introduces a total specialization of a template. Your example by itself isn't actually valid; you need a more detailed scenario before it becomes useful:
template
class A
{
// body for the general case
};
template <>
class A
{
// body that only applies for T = bool
};
int main()
{
// ...
A ai; // uses the first class definition
A ab; // uses the second class definition
// ...
}
It looks strange because it's a special case of a more powerful feature, which is called "partial specialization."