I'm doing some self-study concerning statistics right now and while doing so I want to get some practice with templated classes. As a result, I'm working on a collection of templated classes designed for statistical analysis. What I would like to know is how I would handle creating typedefs for these template classes, if it's even possible. I have created this basic class structure (data and function members omitted for clarity):
namespace Statistics {
template <typename T> class Stats {
};
template <typename T> class CategoricalStats : public Stats {
};
template <typename T> class NumericalStats : public Stats {
};
//typedefs for derived classes, see below
} //end Statistics namespace
The problem that I am having is "Categorical" Stats can also be called "Qualitative" Stats and "Numerical" Stats can also be called "Quantitative" Stats. I would like to define typedefs for each of them to accommodate the alternate names, but my compiler won't accept anything I've tried. In other words, I would like to be able to say either NumericalStats<int>
OR QuantitativeStats<int>
and have them mean the same thing. What do I need to do, if it's even possible? What I have tried:
1.)
typedef CategoricalStats<T> QualitativeStats<T>;
typedef NumericalStats<T> QuantitativeStats<T>;
Error(s):
error C2065: 'T' : undeclared identifier
error C2143: syntax error : missing ';' before '<'
2.)
template <typename T> typedef CategoricalStats<T> QualitativeStats<T>;
template <typename T> typedef NumericalStats<T> QuantitativeStats<T>;
Error(s):
a typedef template is illegal
syntax error : missing ';' before '<'
unrecognizable template declaration/definition
syntax error : '<'
'T' : undeclared identifier
3.)
template <typename T> typedef CategoricalStats QualitativeStats;
template <typename T> typedef NumericalStats QuantitativeStats;
Error(s):
a typedef template is illegal
'Statistics::CategoricalStats Statistics::QualitativeStats' : cannot be a template definition
I have seen 2 versions of the errors that say "a typedef template is illegal" so I'm guessing it can't be done. I know that something like typedef NumericalStats<int> NSint;
is okay, but that doesn't do what I want.
Any other suggestions, comments? Thanks.