4 ms·
AFAIK, the only C++ access specifiers are private, protected, and public. Hardly an "insane number".
by ooterness 2y ago
AFAIK, the only C++ access specifiers are private, protected, and public. Hardly an "insane number".
- ChrisMarshallNY 2y agoWhat about "friend"? Do they still have that? But you have a point. It's a bit overblown, and I'll tamp down the rhetoric.
- bluGill 2y agoThe problem is these all assume you are not under attack. If you are an attacker you can ignore all that. The C++ ABI is known (not to be confused with defined!) on my systems, so if you have a pointer you can add an offset to find any private member and then modify it (even if const you can change it - though the code may not read the change). You can also call any private function from anywhere because how the function is name mangled can be figured out. These tricks are undefined behavior in the C++ standard, but they will work in any implementation if you know how your implementation works under the hood - they will not work on a different implementation, but you can make a different version for different implementations. The above tricks work for most languages, though the details are different for each.