Я не могу понять, какую ошибку я получаю в программе класса шаблонов.
CODE
#include <iostream>
#include<string>
using namespace std;
template <class dataType> class myClass {
public:
void function();
};
template<> class myClass<int> {
public:
void expli_function();
};
template <class dataType> void myClass<dataType>::function() {
cout << "Not an explicit function !" << endl;
}
template <class int> void myClass<int>::expli_function() { //<-- while pointing towards errors compiler points here
cout << "Explicit function !" << endl;
}
int main() {
myClass<string> ob1;
myClass<int> ob2;
ob1.function();
ob2.expli_function();
}
Ошибки:
tester_1.cpp(20): error C2332: 'class' : missing tag name
tester_1.cpp(20): error C2628: '<unnamed-tag>' followed by 'int' is illegal (did you forget a ';'?)
tester_1.cpp(20): error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
error C2244: 'myClass<int>::expli_function' : unable to match function definition to an existing declaration
Почему я получаю эти ошибки и как я могу их исправить?