user5559841
user5559841

Reputation:

Inheritance with abstract template class

Lets say I have an template class and i would like to derive it from an abstract class

I wrote the abstract class declaration as follows:

template<typename T, class Derived>
class AbstractClass{

};

How do I derive my template class correctly? At the moment it looks like:

template <typename T> 
class TemplateClass{};

Upvotes: 1

Views: 149

Answers (1)

SergeyA
SergeyA

Reputation: 62563

I see you are playing with CRTP? The proper way is following:

template <typename T> 
class TemplateClass : public AbstractClass<T, TemplateClass<T> > {};

Upvotes: 3

Related Questions