Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

template in cpp

// templates are used if the logic of function is same but 
// it differs due to data type.

/*Here is an example to show how user defined function print 
can be made to print  data of different data types.*/ 

template <class T>
T print (T a)
{
   cout << a;
}

int main()
{
    print('a');
    print(1);
}
Source by www.cplusplus.com #
 
PREVIOUS NEXT
Tagged: #template #cpp
ADD COMMENT
Topic
Name
1+1 =