[ fromfile: templates.xml id: templates ]
C++ supports four distinct categories of types:
Primitives: int, char, float, double
, etc
Pointers
Instances of class/struct
Arrays
Templates provide a means for the C++ compiler to generate different versions of classes and functions with parameterized types and common behavior.
They are distinguished by the use of the keyword template
, and a template parameter enclosed in angle brackets <>
.
template <class T > class String { ... }; template <class T, int max > Buffer { ... T v[max]; }; String <char> s1; Buffer <int, 10> intBuf10;
Generated: 2012-03-02 | © 2012 Alan Ezust and Paul Ezust. |