1. Home
  2. Computing & Technology
  3. C / C++ / C#

Definition of Generics

By David Bolton, About.com

Definition: Generics is a form of abstraction in developing code. Instead of writing a function or a class for a particular type, it can be written generally to use any type. When an instance of the generic class is instantiated, the type is specified.

Eg. You might create a generic sorting class and when you create an instance of this, the type of entity it sorts is specified. One instance might sort ints, another doubles, and another payroll records.

In C++ this is done through templates. C# 2.0 added generics in 2005 although this is implemented in the .NET Framework, not the language.

Glossary:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Examples:
With templates in C++ there is less need to use macros.
Explore C / C++ / C#
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. C / C++ / C#

©2009 About.com, a part of The New York Times Company.

All rights reserved.