As for the original problem:
The problem here is that the class is nested in a template class. Remember that Class<int> is
a completely different class than Class<float>.
The error is that this line doesn't really make much sense to the compiler:
1 2
|
template <class T>
const Class<T>::InnerClass Class::InnerClass::variable = InnerClass();
|
The whole idea with this line is that you're instantiating
variable
. The reason this doesn't work is because the above is a template, which doesn't instantiate anything.
Since Class<int> is different from Class<float> -- this means that each of those classes have their own 'variable'. The only way the compiler could really fullfill the above statement is to create an infinite number of 'variable's, one for each T. This, of course, is impossible.
What I suspected you could do, was instantiate a specific variable for T. Something like the following.
|
const Class<int>::InnerClass Class<int>::InnerClass::variable = InnerClass();
|
However I get errors even when I try that -- and I'm not sure why because it seems logical to me. In any event that's not much of a solution unless you want to restrict how many types of T there can be.