Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) Template class

 

A template class is 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 [1].

 

 

 

 

 

Examples

 

 

 

 

 

 

References

 

  1. 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.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml