[Exceptional C++ Style] Re: [Exception C++ Style] Item 15 - Uses andAbuses of Access Rights

Balog Pal pasa at lib.hu
Tue Dec 14 09:07:44 EST 2004


> The Pickpocket attempts to change the meaning of the
> class definition by redefining private as public:
>
> #define private public
>
> However, the above is illegal as it attempts to
> redefine a keyword. It also breaks the ODR and
> therefore the same thing applies as was stated

A lighter version of this pickpocket would use

#define private friend class MyClass; private
#include "x.h"
#undef private

That IMHO leaves less chance for the compiler to break anything -- and if 
done everywhere not even breaks the ODR.  As the #define for is considered 
harmless this should be similar. 




More information about the Effective-cpp mailing list