0

I have a template class that depends on another template class. How can TemplateClassB use the type TypeA of TemplateClassA?

template <int L>
class TemplateClassA {
public:
  typedef unsigned TypeA;
};

template <typename E, typename F>
class TemplateClassB {
  TemplateClassA::TypeA var;   //error: invalid use of template-name 'TemplateClassA' without an argument list
}; 

int main(){
  TemplateClassA<1> A = TemplateClassA<1>();
}
Pippi
  • 2,451
  • 8
  • 39
  • 59
  • You need to specify a template parameter for `TemplateClassA` in the declaration of `var`, and also use `typename` – Brian Bi Mar 18 '14 at 22:34
  • Please call them "class templates". They are templates that make classes, not a funny kind of class. – Lightness Races in Orbit Mar 18 '14 at 23:12
  • possible duplicate of [Where and why do I have to put the "template" and "typename" keywords?](http://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords) – Constructor Mar 19 '14 at 07:19

1 Answers1

2

As Brian says, use

typename TemplateClassA<L>::TypeA var;

where L is some int.

iavr
  • 7,547
  • 1
  • 18
  • 53