An introduction to using template classes in C++, that starts extremely simply and builds up from there…
(more…)
Tag: Template classes
-
Templates in C++
-
Printing the contents of STL containers in a generic way
A generic Print function
A way of using STL algorithms combined with template functions as a means of printing the contents of any type of STL container (eg a
std::vector), containing any generic data type (egint,std::stringetc).typenameT defines the generic data type held by the container, whiletypename InputIteratordescribes the STL container iterators passed to it:
(more…) -
Using Template Classes to Handle Generic Data Types in STL Containers
A code snippet with which utilizes both template classes and STL to handle generic data types. In keeping with the spirit of this blog, I have kept the explanation to a minimum and hopefully the code posted below should be self-explanatory. The idea is for readers to get the gist of what I am saying so that they can go off and make up more relevant examples of their own. (more…)