What are generic classes in C++?

A generic class is created to do specific operations which involve generalized logic in a class. A generic class defines specific algorithms within a class. These algorithms are usually common for all the data types.

Syntax of a generic class:

template <class T> class class_name {


Where, T is a placeholder.

Syntax to create a specific instance a generic class:

class_name <type> ob;

Leave a Reply