How do I explicitly instantiate a Template with integer parameter
Example :
foo.h
template<int DIM>
class foo{
public:
foo();
};
foo.cpp
#include "foo.h"
template<int DIM>
foo<DIM>::foo(){
return;
}
main.cpp
#include "foo.h"
int main(){
foo<1> obj;
return 0;
}
Here, I get a main.cpp: undefined reference to `foo<1>::foo()'
Typically we use a template class foo in the cpp file. How do we do this in this case.
thanks
EDIT : Solution Similar to the template class foo, we just need to add
template class foo<1>;