"not delcared in this scope" when subclassing a template

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux