Hi,
the following piece of code can correctly compile (g++ 4.1.2) only if 'this' is specified. Otherwise, it gives the error: 'i' was not declared in this scope (?). Inheriting from, say, X<int> doesn't lead to this problem! I find this rather odd... any hints? Compiler bug?
template<class T> struct X {
int i; // dummy type
};
template<class T> struct Y : public X<T> {
Y() { this->i = 100; }
};
int main() {
Y<double> y; // dummy type
}
the following piece of code can correctly compile (g++ 4.1.2) only if 'this' is specified. Otherwise, it gives the error: 'i' was not declared in this scope (?). Inheriting from, say, X<int> doesn't lead to this problem! I find this rather odd... any hints? Compiler bug?
template<class T> struct X {
int i; // dummy type
};
template<class T> struct Y : public X<T> {
Y() { this->i = 100; }
};
int main() {
Y<double> y; // dummy type
}
Comment