Question

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?

Was it helpful?

Solution

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top