+ 3
Can the private members of a class be accessed without using any public function??
3 ответов
+ 4
No you cannot. Thats the whole point of the permission levels. Even friend functions that are allowed to access/manipulate private class variables [publicly] are technically 'public' functions you're creating to do so.
I do imagine though, with some 'trickery' you could use some virtual functions & templates, mess around with some pointers & structs to hack into the private scope somehow.
Maybe even try to use pointer manipulation of an object's memory allocation that you know are certain sizes.
Basically I think it's possible but not with any conventional use.
+ 3
no, to use private it must be accessed into public
+ 1
Yes, if you use the "friend" keyword you can access private members outside of the class.
More details and examples:
http://en.cppreference.com/w/cpp/language/friend