This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
"not delcared in this scope" when subclassing a template
- From: Alexei Lebedev <alexei dot lebedev at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 23 Feb 2009 20:34:46 -0500
- Subject: "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