Is it possible to access private members of a class in c++.
provided you don't have a friend function and You don't have access to the class definition
You mean using some pointer arithmetic to gain the access ? It is possible but is definitely dangerous. Take a look at this question also: Accessing private members
I think there was some old school trick like this:
#define private public
#include "header.h"
#define private private
But you are strongly discouraged to do this (I've read quickly that the said something about this in the C++ standard) - if you want to read more about this google for "#define private public"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With