What is a template in c++, C/C++ Programming

Templates permit to create generic functions that admit any data type as parameters and return value without having to overload the function with all the possible data types. Until particular point they fulfil the functionality of a macro. Its prototype is any of the two following ones:

template function_declaration; template function_declaration;

The only difference among both prototypes is the use of keyword class or typename, its use is indistinct since both expressions have exactly the similar meaning and behave exactly the similar way.            

 

 

Posted Date: 4/8/2013 5:41:08 AM | Location : United States







Related Discussions:- What is a template in c++, Assignment Help, Ask Question on What is a template in c++, Get Answer, Expert's Help, What is a template in c++ Discussions

Write discussion on What is a template in c++
Your posts are moderated
Related Questions
Write a simple program in C++ to investigate the safety of its enumeration types. Include at least 10 different operations on enumeration types that are incorrect/unsafe things to

(RationalNumber Class) A rational number is a number that can be represented as the quotient of two integers. For example, 1/3, 5/7, 7/2, and so forth are rational numbers (By 2/1

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers. Descriptions of this algorithm are available in algebra books

Write a program called plus that will display asterisks in the shape of a plus sign which has the height and width specified by the user. You must only allow entry of an odd numb

Use of random function: int main(void) {    int i,j;         for(j=0;j       {      // randomize();       for(i=0;i                  printf("%d\n", ran

C Program for MAXIMUM NO, MINIMUM NO AND SORTING   void main() {           int i,j,t;           int a[5];           clrscr();           for(i=0;i

Question : (a) How does a structure differ from an array? (b) Describe how a structure differs from a union? (c) Declare a union called ‘clothes' which consists of the

C Program for EVEN & ODD NO IN ANY MATRICES #include stdio.h> #include conio.h> void main() {           int a[100][100];           int i=0,j=0,r,c,even=0,odd=0;

After p = new Fred[n], how does the compiler know about n objects to be destructed throughout delete[] p? A:  The run-time system hold the number of objects, n, somewhere where

Write a program that predicts users’ age (0-128 years old) with at most 7 questions. The game starts with asking the user whether he/she is younger or older than G (an initial gues