+ 1

Can template class be inherited?

A class that has a template specifications in it can it be inherited?

11th Jul 2017, 9:35 PM
Alaro Abubakar Olayemi
Alaro Abubakar Olayemi - avatar
3 Answers
+ 3
Yes. template <class T> class Base {...}; class Derived: public Base <Derived> {...}; See CRTP idiom for example.
11th Jul 2017, 10:10 PM
soman
0
please what does CRTP means ?
11th Jul 2017, 10:23 PM
Alaro Abubakar Olayemi
Alaro Abubakar Olayemi - avatar
0
Curiously Recurring Template Pattern aka Mixin from above. Used as static polymorphism and to mix in the behavior or data into a derived class. See Wikipedia or DuckDuckGo for the more information
13th Jul 2017, 7:24 AM
soman