ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

هاشم المشارقة
من قبل هاشم المشارقة , 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
من قبل Mohammad Basheer abu ahmad , مشرف كمبيوتر ، الإشراف على الموظفين , قطاع عام

The language that algorithms are written in it

Nasry Al-Haddad
من قبل 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++?

المزيد من الأسئلة المماثلة