Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

what is a template in c++

A template is a simple and yet very powerful tool in C++. The simple idea is to
pass data type as a parameter so that we don’t need to write the same code for
different data types.

For example, a software company may need sort() for
different data types. Rather than writing and maintaining the multiple codes,
we can write one sort() and pass data type as a parameter.
  
C++ adds two new keywords to support templates: ‘template’ and ‘typename’. The
second keyword can always be replaced by keyword ‘class’.
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #template
ADD COMMENT
Topic
Name
4+8 =