Consider the following example:
template <typename T>
struct A {
struct B {
int b;
};
struct C : B {
void f() {
b = 0;
}
};
};
Compiling with GCC 4.8.1 gives the following error:
test.cc: In member function ‘void A<T>::C::f()’:
test.cc:9:11: error: ‘b’ was not declared in this scope
b = 0;
^
However, it bis a member of the parent class b(I used structin the example to make everything public), and if I do a Anon-template, everything compiles.
Why does the compiler give this error and how to avoid it?
source
share