Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inheriting from a template?

I'm reviewing this code:

class WhiteVolatility:public Inverted< IBlackVolatility > {blablabla function declarations}

So class WhiteVolatility is inheriting from a template here... and the template class is an abstract class (IBlackVolatility). I'm having trouble understanding exactly what's going on here -- but my actual question is: why use this kind of design? What is the benefit?

let me know in the comments if my question is impossible to answer and you need more information (I can't tell as I am not confident about what is going on)

like image 675
frickskit Avatar asked Feb 14 '26 23:02

frickskit


1 Answers

Inverted is a class template. Here a specific instance of the template is used, Inverted<IBlackVolatility>, which becomes quite the same thing as any normal class, and WhiteVolatility inherits from that normal class. Nothing weird :)

As for semantic, from the name i would guess that the Inverted template inverts something in its template parameter (here it seems to be the color, since your black volatility becomes white).

like image 182
Drax Avatar answered Feb 16 '26 13:02

Drax