1

I'm trying to compile some old C++ code which doesn't seem to be valid C++ anymore (VS2008 to VS2015). I've managed to narrow the problem down to something which looks like this.

class Any { };

class Parent
{
  template < typename anyT>
  class Child { };
};

template< typename parentT >
class Fail
{
  typedef typename parentT::Child<Any>   ChildT;       // 2 errors
  typename ChildT _child;                              // 2 errors
};

I get this compiler error from Visual Studio 2015.

Error   C2059   syntax error: '<'   TemplateTest    d:\programming\templatetest\example.h   12
Error   C2238   unexpected token(s) preceding ';'   TemplateTest    d:\programming\templatetest\example.h   12
Error   C3646   '_child': unknown override specifier    TemplateTest    d:\programming\templatetest\example.h   13
Error   C4430   missing type specifier - int assumed. Note: C++ does not support default-int    TemplateTest    d:\programming\templatetest\example.h   13  
Azzara
  • 13
  • 2

1 Answers1

0

Where and why do I have to put the “template” and “typename” keywords?

typedef typename parentT::template Child<Any>   ChildT;
ChildT _child;