views:

157

answers:

1

Possible Duplicate:
Accessing private members
Is it possible to access private members of a class?

Is there a good (yes I know this is ugly) way to hack to the private data members of a class?

One brute force approach is to copy the header file and in my copy change private to public. But would there be a better way, say doing

#define private public

or something else?

+4  A: 

There are lots and lots of ways of doing this - all of them bad. Protection in C++ is there for a purpose, to prevent you from making mistakes. It is not there as a security measure. If you want public access, just make things public!

anon
Totally agree with Neil.
acron