How to refer to a nested type of a templated base class

  c++

I have the following structure of base and derived class:

template<class T>
class Base {
public:
  Base();
  
protected:
  struct Foo{
    int a;
    int b;
  };
  int c;
};

template<class T>
class Derived : Base<T> {
public:
  Derived();
...
};

I now want to access the protected part of the base class within the derived class. For c or any other non-type member one can use this->c or Base<T>::c. But how can I construct an instance of Foo for example? this->Foo{x,y} or Base<T>::Foo{x,y} do not work, at least not with g++.

Source: Windows Questions C++

LEAVE A COMMENT