3-Templates___STL

3-Templates___STL - Template is a declaration(similar to...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Template is a declaration (similar to class declaration), which deals with generic types. Templates are evaluated to produce concrete classes when a template-base class is instantiated using a concrete type. Templates are powerful because they allow producing generic classes! C++ Templates C++ Templates Template class example: template<class T, int N> class MyStorageTemplate { public : T Get(int index); // template method void Put(int index); // template method private : T Data[N]; // private data field }; Template function example: template<class T> void MyTemplateFuncion(T param); Validity of template definition is evaluated at compile time it depends on the concrete type used to instantiate the template. C++ Template Declaration C++ Template Declaration The Standard Template Library (STL) is a software library included in the C++ Standard Library. It provides containers, iterators, and algorithms. More specifically the C++ Standard Library is based on the STL Library published by SGI. Both include some features not found in the other. SGI's STL is rigidly specified as a set of headers, while ISO C++ does not specify header content, and allows implementation either in the headers, or in a true library....
View Full Document

This note was uploaded on 03/18/2010 for the course CSE 122 taught by Professor Yoxheimer,ericch during the Spring '07 term at Penn State.

Page1 / 9

3-Templates___STL - Template is a declaration(similar to...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online