-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Expert C++ - Second Edition
By :
A class template defines a family of classes, and it is often used to implement a container. For example, the C++ Standard Library contains many class templates, such as std::vector, std::map, std::deque, and so on. In OpenCV, cv::Mat is a very powerful class template, and it can handle 1D, 2D, and 3D matrices or images with built-in data types such as int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, float, double, and so on.
Similar to function templates, as shown in Figure 3.2, the concept of class templates contains a template creation syntax, its specialization, and its implicit and explicit instantiations:
Figure 3.2 – Class template and its instantiation
In part I of the preceding diagram, with a certain syntax format, we can create a class template for generic types, also known as a primary template, and it can be customized for special types with different member functions and/or variables. Once we have a class template...