Answer Posted / akshata
Abstraction of structure independently of type is genericity
(pronounced jen-err-iss-it-ee).
E.g. Compare these two functions to return the maximum of
two numbers.
integer maxInteger (integer param1, integer param2)
{
if (param1 > param2)
{ return param1; }
return param2;
}
float maxFloat (float param1, float param2)
{
if (param1 > param2)
{ return param1; }
return param2;
}
It seems silly to have to write the two functions but if a
language doesn't allow you to pass an integer to a function
that requires a floating point parameter (or vice versa)
then this is exactly what you must do.
Some languages allow you to to write a single generic
function that will serve the same purpose for both integers
and floating point values (or any other types you like for
that matter). In general, such a function might look a
little like this.
TYPE max (TYPE param1, TYPE param2)
{
if (param1 > param2)
{ return param1; }
return param2;
}
| Is This Answer Correct ? | 7 Yes | 1 No |
Post New Answer View All Answers
How would you design a gravity dam for holding back water?
What is Lease Line?Why power cord is not required to NT Boxex on which lease is connected ?Why we use use NT BOXEs for ISDN and Lease line?
How to recyling of Expired Computer/Laptop,Mouse,CPU & Key Board (Warranty)?
why we use conio.h in c programming?
Write a shell script to delete all files present in a directory “dir1”. Any error, if it occurs while carrying out this operation should be stored in a file errorlog
briefly explain about your project? please tell me about this answer . my current project is ERP domain web based application.please please help me
what are enumerations in c language?
Hi manikandhan, my name is ruby. Can u pls forward the conduct/character certificate on my Id. ruby_cse07@yahoo.co.in what details shall i require for this certificate. pls help me out with this..its really very urgent.. let me know soon bcoz my interview is on 19th septemper in mumbai...
BEL old probationary engineering questions and answers
I an doing Engineering in IT(4th year). i want to know what is the scope or .NET and Linux, and which is better for carrier
what is the definition(body) of a default constructor in c++?
How to defaultly populate charges in Clear transactions window for Cash Management?
what is the difference between public static void main (String args[]) and static public void main(String args[]) in java?
Hi All... PLease send me if anyone have "Information Security Officer" Aptitude papers. Please Mail me at mannusanghi@gmail.com
plz snd me sbi probationofficers papers to my id archpa@gmail.com