Start networking and exchanging professional insights

Register now or log in to join your professional community.

هاشم المشارقة
by هاشم المشارقة , Key Account Manager , Advanced United Systems Ltd. ( A member of Taj Holding Group)

Generic programming means that you are not writing source code that is compiled as-is but that you write "templates" of source codes that the compiler in the process of compilation transforms into source codes. The simplest example for generic programming are container classes like arrays, lists or maps that contain a collection of other objects. But there's much more to generic programming. In the context of C++ (and called meta programming) it means to write programs that are evaluated atcompile time.

Mohammad Basheer abu ahmad
by Mohammad Basheer abu ahmad , مشرف كمبيوتر ، الإشراف على الموظفين , قطاع عام

The language that algorithms are written in it

Nasry Al-Haddad
by Nasry Al-Haddad , software engineer , Element^n

I think the question should be "What is generic programming?" or "How to apply generic programming in C++?"

Generic programming is a programming style, and is available in several languages including C++, Java, ...

This style is generic with respect to data type. Generics are applied to functions or classes.

Instead of providing a specific type to a function argument or returned data-type, you specify a generic type. This generic type gets replaced by a specific type.

In C++, you use templates to achieve generic programming.

Example from Generic Programming:

template <typename T> T max(T x, T y) { return x < y ? y : x; }

This function could be called providing "int" arguments, "double" arguments, ... So T is your generic type, which gets replaced by the type of the arguments you supply in the function call.

Notice also that the return value is also T, the same type of the supplied arguments.

You could also provide several genetric types for a single function or single class.

A good explanation of this is also available at StackOverflow: What is the meaning of "generic programming" in c++?

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.