Protected or Private?

As the designer of base class, you may hesitate whether to use private or protect access control. Then, let’s try the following examples: 1. Call protected member function#include <cstdio>class A{protected:    void b() {printf(“Oops!\n”);}};void f(A* a){    class A_hack:public A    {        friend void f(A*);    };    static_cast<A_hack *>(a)->b();}class B{public:    void f(A* a)    {        class A_hack:public A        {            friend B;        };        static_cast<A_hack *>(a)->b();    }};int main(){    f(NULL);    B().f(NULL);} Although the result of the cast is undefined as stated in the standard, if no this pointer adjustment happens and the layout of A is the same…

1

IDA Pro 5.3 Demo is released

IDA Pro is the world-class disassembler. It’s a very useful reverse engineering tool. Now the demo of the newest version 5.3 is available: IDA Pro 5.3 demo download You can also try the freeware version (a little out of date): IDA Pro 4.9 Freeware

1