Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Class Template | Class
C++ Templates
course content

Course Content

C++ Templates

C++ Templates

1. Creating First Template
2. Templates Usage
3. Template Specialization
4. Class
5. Template Metaprogramming

Class Template

cpp

main

copy
12345678910
template <typename T> class Example { public: T value; }; int main() { Example<int> obj; }
  • The template definition itself (template class MyTemplate { ... };) serves as a blueprint for creating classes.
  • The instantiated class (Example) is an example of a class that uses templates, where the template is specialized with a specific type.

Note

Examine is a template class that can be instantiated with any type T. However, until you specify a particular type, MyTemplate remains a template, not a concrete class.

Everything was clear?

Section 4. Chapter 1
We're sorry to hear that something went wrong. What happened?
some-alt