Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

(C++) Template class

 

A class that takes a template parameter. Or: a template class defines how a group of classes should be generated, as opposed to a class in C++ as being how the group of objects should be generated:

 

 

 

template <class T>

struct MyClass

{

T x;

};

 

int main()

{

MyClass<int> m;

m.x = 10;

}

 

 

 

Many STL classes are template classes.

 

There is no semantic difference between class and typename in a template-parameter [0] .

 

References

  • C++. International Standard. ISO/IEC 14882. Second edition. Paragraph 14.1.2.

     

     

    Go back to Richel Bilderbeek's C++ page.

    Go back to Richel Bilderbeek's homepage.