This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

"not delcared in this scope" when subclassing a template


Hi,

The following code seems to be OK to me:

template<class X>
class Base {
protected:
  X *elems;
};
template<class A>
class Derived: public Base<typename A::value_type> {
  void Test() {
    if (elems) {
    }
  }
};

Attempting to compile it gives the following error:

templates.cpp:18: error: 'elems' was not declared in this scope

True, elems was not declared in this scope.. it was declared in THAT
scope. Why is it an error and what is going through GCC's mind when it
compiles this?

Thanks,
Alexei


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]