CoolInterview.com - World's Largest Collection of Interview Questions
Send Free SMS
 Interview Questions  
 Our Services  


INTERVIEW QUESTIONS LANGUAGES C++ DETAILS
Question :
What is a template?



Category C++ Interview Questions
Rating (1.0) By 1 users
Added on 7/19/2006
Views 2883
Rate it!
Answers:

Template is used for creating generic functions as well as data members



Templates allows us to write a class or functions without different parameters...
Example:- If you want to write the function which can be called by passing int as well as float and return type is also generic means it returns int if you pass int to the function and returns float if you pass float to it then write it as..


template <class T>
T fun_name(T a)
{
return a;
}


above is the function template
now you can call it as

int i=10,j;
j=fun_name(i);

as well as

float f=10.23,g;
g=fun_name(f);

it means fun_name() is generic its arguments are also generic as well as return type is also generic



 Posted by: sachin    

Contact sachin  Contact sachin

template is used for generic functions. using templates we can pass any type of arguments to a function as well as we can receive any type of values from the function. tempaltes reduces the program length. only one function is enough for any kind of calling functions.



 Posted by: mahesh    

Contact mahesh  Contact mahesh


If you have the better answer, then send it to us. We will display your answer after the approval.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification  Enter the above shown code:*
Inform me about updated answers to this question

   
Related Questions
View Answer
What do you mean by inline function?


View Answer
What is virtual class and friend class?
View Answer
What is function overloading and operator overloading?


View Answer
Difference between realloc() and free()?


View Answer
What do you mean by binding of data and functions?


View Answer
What is friend function?


View Answer
What is public, protected & private?


View Answer
What is polymorphism? Explain with an example?


View Answer
What is a class?


View Answer
What is the difference between structures and classes in C++?
View Answer

Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

Notify me when better answer is posted!
Email:

View ALL C++ Interview Questions

User Options
Sponsored Links


Copyright ©2003-2010 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions
Page URL: http://www.coolinterview.com/interview/6156/default.asp?cachecommand=bypass


Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Free SMS | Dedicated Servers | Joke of the Day

0.66