Q:

Can we access private data members of a class without using a member or a friend function?

0

Can we access private data members of a class without using a member or a friend function?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

total answers (1)

C++ Interview Questions For Experienced

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Can virtual functions be private in C++?... >>
<< Why is a pure virtual function initialized by 0 in...