0

I have the following code example below, with two template classes, one base and one derived. I need to access a type in the base class from the derived class, but it says that it does not name a type. Why is this the case?

'Parameter' does not name a type

using namespace std;

template<typename PointT>
class BaseClass{
public:
    BaseClass(){}

    class Parameter{
        Parameter(){}
    };
};

template<typename PointT>
class DerivedClass : public BaseClass<PointT>{
public:
    DerivedClass(){}

    class ParameterExtended{
        Parameter x;
    };
};
Raaj
  • 363
  • 1
  • 3
  • 12

1 Answers1

0

You need this:

typename BaseClass<PointT>::Parameter x;
John Zwinck
  • 239,568
  • 38
  • 324
  • 436
  • this seems to work. Also, i can't seem to access any variables from my base class either in the derived class. says its not declared in this scope – Raaj Mar 18 '17 at 08:31
  • 2
    @Raaj Maybe [this is the issue](http://stackoverflow.com/questions/4643074/why-do-i-have-to-access-template-base-class-members-through-the-this-pointer)? – PaulMcKenzie Mar 18 '17 at 08:37