I have a class ClassType
that is a parent for some other classes. I want to create a template that can only have the ClassType
(and its children) type, like:
template< ClassType > class ClassABC
{
std::shared_ptr< ClassType > m_member;
// ...
public:
ClassABC< ClassType >(std::shared_ptr< ClassType >& objIn) : m_member(objIn) {}
void foo( int v1, int v2); // the function does an operation general to ClassType
}
But it is not correct. Is there a way to do it?
I want to have some kind of specializations like:
template<> class ClassABC< B >
{
std::shared_ptr< B > m_member;
// ...
public:
ClassABC< B >(std::shared_ptr< B >& objIn) : m_member(objIn) {}
void foo( int v1, int v2); // the function does some operation specific to B
}
and for the other classes (A
and C
) it does the generic operation.