Наследование шаблонов C++ вызывает ошибку "неполного типа"
Я пытаюсь определить производный класс, который наследуется от базового шаблона шаблона следующим образом
test.h
template <class T>
class test
{
public:
void something (T x ) ;
};
test.cpp
#include "test.h"
template<>
class test<int> {
public:
void something (int x ) {
cout << x ;
}
} ;
test2.h
class test2 : public test<int> {
public:
test2() = default;
//~test2();
};
test2.cpp
#include "test.h"
int main(int argc, char const *argv[])
{
test2<int> a ;
return 0;
}
И я получил такие ошибки, как
expected template-name before ‘<’ token
class test2 : public test<int> {
expected ‘{’ before ‘<’ token
In function ‘int main(int, const char**)’:
test2.cpp:8:8: error: aggregate ‘test2 a’ has incomplete type and cannot be defined
test2 a ;
Мои вопросы, как правильно определить наследование шаблона?
если test2 inheirt test типа int, сможет ли он использовать метод теста другого типа?
Спасибо!