Using the Template Argument as the Superclass

Using the Template Argument as the Superclass

When you need to add the same member function to several classes, you can use a template class, derived from its template argument.

 template class T : public P {public:  void f() { cout << "f()" << endl; } _// added member function};typedef T APlus;typedef T BPlus;

Added in such a manner, this member function calls any other member functions (not defined in the template). However, you have to be sure that all the base classes have them.

This technique can also be used to override a virtual member function of a bunch of classes.

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular