I'm in the process of learning c++. Now i understand that a derived class cannot access its base class private members, but why a templatized one can ?
for instance something like this works fine:
class base {
static int x;
};
template<typename T>
class derived: public base{
T t;
public:
void setx(int i) {x=i;}
int getx(){return x;}
};
I'm using gcc 5.4 on linux.
This is a known bug of GCC, which seems to fail in performing access checking correctly in templates. See Bug 58740.
Unfortunately it's still not fixed.
BTW: Clang fails to compile, as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With