Computer Science - Object Oriented Programming Using C++ - Discussion
Discussion Forum : Object Oriented Programming Using C++ - Section 1 (Q.No. 23)
23.
The generic type in a template function
Discussion:
6 comments Page 1 of 1.
Harpreet said:
1 decade ago
Please explain this.
Udayashokkumar.nunna said:
1 decade ago
T indicates here generic data type there is necessary instead of declaring any data type for eg: function(Ta,Tb).we can use function(int a,int b), function(a,b),function(char a,char b)
Divya said:
8 years ago
Generic data type means?
Lakhan Ghayade said:
5 years ago
In short, for any particular function using T as a datatype, can use any datatype as an argument.
Lakhan Ghayade said:
5 years ago
Generic is the idea to allow data types like int, char, string Or user defined types. Etc. To be in the methode, class, Or interfaces.
Jasminder Singh said:
1 year ago
Generics allow programmers to write a function that can take any type of anrugments.
Example : T sum(T a, T b) {
return a+ b;
}
The sum function can take any type of data like string, integer, even, char, or float etc. We don't need to explicitly define the return type and paramerter type.
Example : T sum(T a, T b) {
return a+ b;
}
The sum function can take any type of data like string, integer, even, char, or float etc. We don't need to explicitly define the return type and paramerter type.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers