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
Can one be shocked holding a wire carrying a very large current with a low voltage source?
Differences between Java and C++? which is faster?
how strcpy usingrecursive function
Qatar petroleum will call me for an technical phone interview as safety officer Please let me know what kind of question they asked ? any idea about this written test ?
Hi i want some previous interview questions and answers for KVB Bank.
if a customer's blackberry stopped syncing their calendar wirelessly what would you do?if a customber deleted mail from his blackberry but it did delete from his mailbox how would ypu resolve this
How we calculate the recovery of steam as per coal in a boiler if we know the calorific value of coal?
please tell me difference between router and cisco router
AD backups and restoration
1) There is a circular pizza with negligible thickness that is cut into 'x' pieces by 4 straight line cuts. What is the maximum and minimum value of 'x' respectively 2)A ship leaves on a long voyage. When it is 18 miles from the shore, a seaplane, whose speed is 10 times that of the ship is sent to deliver mail. How far from the shore does the seaplane catch upon with the ship? 3) If the distance traveled (s) in time (t) by a particle is given by the formula s = 1+ 2t+3t2+4t3, then what is the distance traveled in the 4th second of its motion? 4)3 men finish painting a wall in 8 days. Four boys do the same job in 7 days. In how many days will 2 men and 2 boys working together paint two such walls of the same size?
pls send me rrb se(s&t)questions
What is "strstream" ?
find the salary of an employee where employee number is known
what is rapid application development
I have Cleared Bank of India Clerical Examination.I just want to know how to prepare for interview and what are the parriculars that I have to submit......Pls someone help me with it