What is C++ generic programming?
In this issue, the editor will bring you about what C++ generic programming is. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Generic programming has the same goal as object-oriented programming, even though techniques for reusing code and abstracting common concepts are simpler. But object-oriented programming emphasizes the data aspect of programming, while generic programming emphasizes independence from specific data types.
This paper introduces another branch of C++ programming, which is juxtaposed with object-oriented programming-generic programming, mainly introducing three parts: function template, class template and member template.
Generic programming
Template is an important idea of generic programming. STL (Standard Template Library, Standard template Library) is an example function template implemented by template.
Compared with function overloading (functions with the same name but different parameter lists in the same scope), the function template only needs one function to realize part of the function overloading (the same number of parameters is of different types. Function overloading requires the definition of multiple functions with different parameter lists with the same name)
Template / / you can also write template where class and typename have the same function as void tfunc (T & t, Y & y) {cout