Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1
Generic data type are those types of templates where programmer uses a general data type like T. And this T can be int, float, char, bool, double, etc. Whatever user require. Like template <class T> T small(T x, T y) { return(x<y? x:y) } When such type of code will be used then programmer don't have to worry about the data type used for the arguments or return type of function. With the help of this single function user can use to get smaller number between any data type. Like int, float, double etc. Otherwise programmer have to overload his function for other data type if not used generic data type. int small (int x, int y) float small(float x, float y) double small(double x, double y)
16th Oct 2016, 6:05 PM
mahesh kumar
mahesh kumar - avatar