ITWissen.info - Tech know how online

template programming

Templates are templates that provide program code sequences in a generally reusable form. Their definition is independent of it, with which data they act finally, since these are specified only with the use of a Template. One speaks in this connection also of the instantiation of a Template by the compiler.

The basic idea of the Template programming is by the re-use of the program code to reduce its susceptibility regarding errors, and to represent the entire implementation in more abstract - also more compact - form. In particular for example algorithms for stack and Queue structures, sequences for sorting algorithms or also generally usable administration operations offer themselves to work with Templates.

In the object-oriented programming as for example in C++ or the programming language D templates are possible in connection with functions and classes. By the C++ standard library a number of templates are already given in form of a template framework. The name range of function and class templates is in each case an own. Here templates are in particular in the combination with the mechanisms of the inheritance and the overloading of operators meaningfully applicable. "D" does not support the multiple class inheritance expressly, but also there the same functionality is attainable over the use of mixins. Another interesting aspect of template programming is its possibility of specialization. Thus one can realize class and function templates for certain data types as Template arguments.

A still higher level of the abstraction is possible by the definition of Templates, which are used again as parameters of Templates. In connection with Templates also frequently the speech is from generic programming.

Informations:
Englisch: template programming
Updated at: 15.07.2009
#Words: 268
Links: program, code, data, connection, compiler
Translations: DE
Sharing:    

All rights reserved DATACOM Buchverlag GmbH © 2024