Teachers Paradise School Supplies Teacher Resources Free Encyclopedia
Teachers Paradise FREE Teaching Resources
Home Arts Crafts Audio Visual Equipment Office Supplies Teacher Resources
Main Page | Edit this page

Generic programming

In computer science, generics are a technique that allows one value to take different datatype (so-called polymorphism) as long as certain contracts (so-called subtype) are kept. The programming style with it is called "generic programming".

Among OOP languages, C++, Beta, Eiffel, Ada, and later versions of Java provides generic facility. In C++, templates support generics and popularized the notion of generics.

For example, in C++ code,

template 
T max (T x, T y)
{
 if (x < y)
   return y;
 else
   return x;
}

In this case, a pseudo-datatype T is called "subtype". T can be anything that can be compared.

Uncommon, template metaprogramming is a way of making algorithms evaluate when your code is compiled.


See also Partial evaluation




Pay for Educational Supplies & Teaching Supplies with Visa, Master Card, American Express, Discover or Paypal.
TeachersParadise.com HOME | Safe Shopping Guarantee | Help Desk
All trademarks & brands are the property of their respective owners.
Legal Notice 2000-2008 TeachersParadise.com, Inc. All Rights Reserved