Header

Thursday 5 September 2013

IGNOU BCA 3rd sem Solved Assignment - What is template? Write appropriate statements to create a template class for Stack data structure in C++.

What is template? Write appropriate statements to create a template class for Stack data structure in C++.  
Ans
Function Templates
Class Templates
Templates are the foundation of generic programming which involves writing code in a way that is independent of any particular type.
A template is a blueprint or formula for creating a generic class or a function. The library containers like iterators, and algorithms are examples of generic programming and have been developed using template concept.
There is a single definition of each container, such as vector, but we can define many different kinds of vectors for example, vector <int> or vector <string>.
You can use templates to define functions as well as classes
Pointers, References and Arrays with Templates
Multiple Types with Function Templates
Function Template - Template Function
Explicit Template Argument Specification
Default Arguments with Function Templates

Multiple Types with Class Templates
Non-type Template Arguments
Template Class as Argument to Class Template
Default Template Arguments with Class Templates
Class' Methods as Function Templates

No comments:

Post a Comment