Course Content
C++ Templates
C++ Templates
2. Templates Usage
3. Template Specialization
4. Class
Class Template
main
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