#define private public

The other day I was talking to a friend and he told me about something he was doing. He has a C++ dll and the according h-file. Now he wanted to access some private methods in the dll. There is no reflection in C++ and he does not have the source code. How can you access the private methods?

Simple!

#define private public

I googled it and found that apparently this is a common technique in unit testing. Wonderful! :-)

Leave a Reply

Your email address will not be published. Required fields are marked *