Results 1 to 5 of 5

Thread: What are genericity in C++?

  1. #1
    Join Date
    Nov 2009

    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.

  2. #2
    Join Date
    May 2008

    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++.

  3. #3
    Join Date
    Apr 2008

    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,
    Class templates.
    Another name for the class templates in C++ is 'genericity'.

  4. #4
    Join Date
    Oct 2005

    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.

  5. #5
    Join Date
    Oct 2010

    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.

Similar Threads

  1. Genericity and Inheritance
    By Ricky58 in forum Software Development
    Replies: 4
    Last Post: 30-10-2009, 11:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts