I have two classes, which I shall call classA and classB.
In classA I have some types defined, such as T5.
In classB I use such types defined in classA.
In order to avoid writing
typename classA<T1,T2>::T5
throughout my code, I want to create a class indipendent type,
which I would be able to call directly by simply its name - templatedClassA
in the example. The template paremeters would still be parametric, and I would
define them in future projects using classA and classB.
#include <cstdlib>
#include <iostream>
using namespace std;
//classA
template <class T1, class T2>
class classA
{
public:
typedef T1 T5;
classA();
};
template <class T1, class T2>
classA<T1,T2>::classA(){}
//end classA
template <class T1, class T2>
typedef classA<T1,T2> templatedClassA;
template <class T1, class T2>
typedef typename classA<T1,T2>::T5 T6;
//classB
template <class T3, class T4>
class classB
{
public:
classB();
};
template <class T3, class T4>
classB<T3,T4>::classB(){}
//end classB
int main(int argc, char *argv[])
{
classB<int, double> classBInstance;
system("PAUSE");
return EXIT_SUCCESS;
}
When compiling the above code, I get the following two errors:
template declaration of `typedef class classA<T1, T2> templatedClassA'
template declaration of `typedef typename classA<T1, T2>::T5 T6'.
What am I doing wrong?