- Expert C++
- Vardan Grigoryan Shunguang Wu
- 182字
- 2021-06-24 16:34:06
Class templates
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 the following diagram, the concept of class templates contains a template creation syntax, its specialization, and its implicit and explicit instantiations:
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, in part II, the compiler will instantiate it to template classes either explicitly or implicitly based on the application's demand.
Now, let's look at the syntax for creating a class template.
- 演進(jìn)式架構(gòu)(原書第2版)
- Python概率統(tǒng)計(jì)
- Web前端開發(fā)技術(shù):HTML、CSS、JavaScript(第3版)
- Java EE 6 企業(yè)級(jí)應(yīng)用開發(fā)教程
- iOS開發(fā)實(shí)戰(zhàn):從零基礎(chǔ)到App Store上架
- Mastering Swift 2
- Mastering ROS for Robotics Programming
- Unity UI Cookbook
- Spring技術(shù)內(nèi)幕:深入解析Spring架構(gòu)與設(shè)計(jì)原理(第2版)
- Extending Unity with Editor Scripting
- Magento 2 Beginners Guide
- Visual FoxPro數(shù)據(jù)庫程序設(shè)計(jì)
- Django 3 Web Development Cookbook
- Go語言從入門到進(jìn)階實(shí)戰(zhàn)(視頻教學(xué)版)
- Deep Learning with Theano