Is template and a function similar? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is template and a function similar?

what is the difference between them?

28th May 2017, 7:11 AM
Ashok P R
Ashok P R - avatar
14 Answers
+ 4
see example. in example. variable output can be anything when we supply a std::string to output variable. the compiler creates a function for that type. void jSays(const std::string output); if we supply an int the compiler will create a function that accepts type int. void jSays(const int output);
28th May 2017, 7:18 AM
jay
jay - avatar
+ 4
Australia
28th May 2017, 7:25 AM
jay
jay - avatar
+ 4
lol. So I have been told 😊
28th May 2017, 7:28 AM
jay
jay - avatar
+ 3
template is a template. It is an outline of a thing. Its structure. a function is a function. A templated function is a function that can accept many different data types. think overloading but without the overloading.
28th May 2017, 7:16 AM
jay
jay - avatar
+ 3
typename
28th May 2017, 7:23 AM
jay
jay - avatar
+ 2
your name is like an Indian that's why
28th May 2017, 7:26 AM
Ashok P R
Ashok P R - avatar
+ 1
@jay so template is a function where it can accept all data types right??
28th May 2017, 7:18 AM
Ashok P R
Ashok P R - avatar
+ 1
ok
28th May 2017, 7:20 AM
Ashok P R
Ashok P R - avatar
+ 1
where are you from
28th May 2017, 7:21 AM
Ashok P R
Ashok P R - avatar
+ 1
can you say the keyword that declares a variable which can accept any datatype??
28th May 2017, 7:21 AM
Ashok P R
Ashok P R - avatar
+ 1
ok thank you
28th May 2017, 7:24 AM
Ashok P R
Ashok P R - avatar
+ 1
where are you frim
28th May 2017, 7:25 AM
Ashok P R
Ashok P R - avatar
+ 1
ok
28th May 2017, 7:25 AM
Ashok P R
Ashok P R - avatar