i have an old codebase here, where they used protected member variables. Whether or not this is a good idea can be discussed. However, the code must have compiled fine with gcc3.
I have a derived template class Bar that uses protected member x from class template Foo like so
template <class Something> class Foo {
public:
// stuff...
protected:
some::type x;
}
template <class Something> Bar : Foo<Something> {
public:
void cleanup();
}
And in the method declaration of cleanup() there is something done with x
template <class Something> void Bar<Something>::cleanup() {
doSomeThingCleanUpLike (x);
}
This does not work with gcc4, although it should have worked with gcc3. It works when I change it to
doSomeThingCleanUpLike (this->x);
Why is that the case?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…