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
operation of carrier aided protection and what is the basis for choice of frequncy in powerline carrier system
I am selected interview for computer sc.please give me some information how many types question asked in interview.my id is sumanadas10@gmail.com
explain inflation ,deprication ,time of value & pf tariff
what is difference between shell commands and shell scripting commands or both r same?
HOW CAN YOU RELATE THE FUNCTION WITH STRUCTURE EXPLAIN WITH APPROPRIATE EXAMPLES
I am helping a friend to design a concert hall. No need for super architectural show off. Just a rectangular box. Knowing that in my country constructions are done with reinforced concrete and concrete blocks and that the hall's dimensions are, length: 75 meters, width: 32m height: 9m, and that there should not be any columns inside, what would be the size of the columns, beams and roof slab ?
how to delete four out of five duplicate records in a table using sql
when load increase in generator in island mode, why turbine rpm is reduced
Hi dost here Alok Kumar please send question pattern for NIC at godinall.kumar1@gmail.com or alok.iitb07@gmail.com
CSS corp interview process and placement papers
Name a accredited or govt approved university which have 100% online engineering course
why one should join accenture?
what is the working of tcp/ip?
hi ,,,,I m going to attend corporate bank exam of specialist IT officer, I don't Know What type of question arise in interview..some suggest me my email id is surinder.singh.btech@gmail.com
Implement the dictionary operations INSERT, DELETE, and SEARCH using singly linked, circular lists. What are the running times of your procedures?