
Untitled
By: a guest on
May 6th, 2012 | syntax:
None | size: 0.57 KB | hits: 10 | expires: Never
// % cat foo.cpp
#if USE_TEMPLATES == 0
class A { protected: void f() {} };
class B : public A { using A::f; };
int main() { B b; b.f(); }
#else
template<int AI> class A { protected: void f() {} };
template<int BI> class B : public A<BI> { using A<BI>::f; };
int main() { B<3> b; b.f(); }
#endif
// % g++ -DUSE_TEMPLATES=1 -o foo foo.cpp
// % ./foo
// % g++ -DUSE_TEMPLATES=0 -o foo foo.cpp
// foo.cpp: In function ‘int main()’:
// foo.cpp:2: error: ‘void A::f()’ is protected
// foo.cpp:4: error: within this context