Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



What are genericity in C++?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 11-11-2009
Member
 
Join Date: Nov 2009
Posts: 67
What are genericity in C++?
  

Hi to all.
I am interested in software programming. I have already used C, C++, Java and C#. I am now preparing for Microsoft Certification. Recently I was questioned about Genericity in C++. But I have not heard about this term earlier. Now I am confused as to what actually is this Genericity. I was given the hint that it is related to C++ programming. Help me.

Reply With Quote
  #2  
Old 11-11-2009
Member
 
Join Date: May 2008
Posts: 2,286
Re: What are genericity in C++?

Not only you but there are many who would not know what is Genericity in terms of C++. Even I was not knowing what Genericity is. Infact I doubted that is there any term Generity that exists in C++. But I was told that it does exists. C++ has a concept called Templates. These templates include a class template. These class templates are called as Genericity in C++.
Reply With Quote
  #3  
Old 11-11-2009
Member
 
Join Date: Apr 2008
Posts: 1,997
Re: What are genericity in C++?

C++ language supports a unique utility called Templates. The basic principle of Templates is to help the user to make classes and function to operate with generic types. C++ has categorized templates into two types:
Function templates,
and
Class templates.
Another name for the class templates in C++ is 'genericity'.
Reply With Quote
  #4  
Old 11-11-2009
Member
 
Join Date: Oct 2005
Posts: 2,387
Re: What are genericity in C++?

I can understand how confused you are. The term Genericity and its meaning is very rarely known to anyone. There is a very distinct feature of C++ that provides a mode to make a class to handle any datatype or allows you to design the behaviour of the class irrespective of the datatypes to be handles by that class. This is feature of C++ is called Templates and since it is applied on classes it is called class templates. The programming done in the above mentioned manner using templates is called Generic programming. In a simplified manner, class templates are also called as Genericity.
Reply With Quote
  #5  
Old 08-10-2010
Member
 
Join Date: Oct 2010
Posts: 1
Re: What are genericity in C++?

The software components of a program have more than one version depending on the data types of arguments.This features allows declaration of variables withot specifying exact data type.The compiler identifies the data type at run time.The programmer can create any type of function that can be used for any type of data.The template feature in C++ allows generic programming.


Generic programming is a style of computer programming in which algorithms are written in terms of to-be-specified-later types that are then instantiated when needed for specific types provided as parameters. This approach, pioneered by Ada in 1983, permits writing common functions or types that differ only in the set of types on which they operate when used, thus reducing duplication. Software entities created using generic programming are known as generics in Ada, Eiffel, Java, C#, and Visual Basic .NET; parametric polymorphism in ML, Scala (possibly the only modern language that supports both parameterized types originating from functional languages and virtual types from the OO paradigm) and Haskell (the Haskell community also uses the term "generic" for a related but somewhat different concept); templates in C++; and parameterized types in the influential 1994 book Design Patterns. The authors of Design Patterns note that this technique, especially when combined with delegation, is very powerful but that "Dynamic, highly parameterized software is harder to understand than more static software."
Generic programming refers to features of certain statically typed programming languages that allow some code to effectively refine the static type system. For instance in C++, a template is a routine in which some parameters are qualified by a type variable. Since code generation in C++ depends on concrete types, the template is specialized for each combination of argument types that occur at some instantiation. Generic programming is used to implement the STL libraries to define containers, iterators, and algorithms. Examples of containers are vectors, queues, sets, maps, and lists and hash tables and functions such as a particular sorting algorithm for objects specified in terms more general than a concrete type.
Generic programming pioneer Alexander Stepanov wrote: "Generic programming is about abstracting and classifying algorithms and data structures. It gets its inspiration from Knuth and not from type theory. Its goal is the incremental construction of systematic catalogs of useful, efficient and abstract algorithms and data structures. Such an undertaking is still a dream.". Following Stepanov, Bjarne Stroustrup defined generic programming without mentioning language features: "[l]ift algorithms and data structures from concrete examples to their most general and abstract form.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "What are genericity in C++?"
Thread Thread Starter Forum Replies Last Post
Genericity and Inheritance Ricky58 Software Development 4 30-10-2009 11:41 PM


All times are GMT +5.5. The time now is 11:17 AM.