I'm getting "error: ‘A’ is an inaccessible base of ‘B’" in static_cast of the following example:
template<typename Derived>
class A {
protected:
void funA() { static_cast<Derived *> (this)->funB(); }
};
class B: protected A<B> {
public:
void funB() {}
void funC() { funA(); }
};
int main() {
B().funC();
return 0;
}
But it compiles/works well when using reinterpret_cast or C-style type cast ((Derived *)this)->funB() instead. Is this behavior correct?
Compiler used: gcc version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC).
Thanks.