Can we access private data members of a class without using a member or a friend function?
Answer:
You can’t. That member is private, it’s not visible outside the class. That’s the whole point of the public/protected/private modifiers.
Note: You could probably use dirty pointer tricks though, but my guess is that you’d enter undefined behavior territory pretty fast.
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Answer:
You can’t. That member is private, it’s not visible outside the class. That’s the whole point of the public/protected/private modifiers.
Note: You could probably use dirty pointer tricks though, but my guess is that you’d enter undefined behavior territory pretty fast.
need an explanation for this answer? contact us directly to get an explanation for this answer