I was working with code from an answer to this question:
#include <iostream>
#include <string>
using std::cin;
using std::cout;
template<int N, int I=N-1>
class Table : public Table<N, I-1>
{
public:
static const int dummy;
};
template<int N>
class Table<N,0>
{
public:
static int array[N];
static const int dummy;
};
template<int N, int I>
const int Table<N,I>::dummy = Table<N,0>::array[I] = I + 0*Table<N,I-1>::dummy;
template<int N>
int Table<N,0>::array[N];
template<int N>
const int Table<N,0>::dummy = 0;
template class Table<5>; //<-what does this statement do? The program does not work without it.
int main()
{
std::string s;
int *array = Table<5,0>::array;
for(int i = 0; i < 5; i++)
{
cout << array[i] << " ";
}
cout << "\n";
cout << "Press ENTER to exit.\n";
std::getline(cin, s);
}
The line template class Table<5>;
just before the start of the main routine is marked off with a comment in the listing and shows a use of the work "template" that I am not familiar with. What is the justification for this line of code?