C++: How to Access Private Members VALIDLY

Intro In most contexts, private members are forbidden to access outside its class. But as the title says, I’ll show you a way to validly access them. Valid, here, I mean it’s well-defined according to the standard, and not causing undefined behavior. This post is inspired by a post more than 10 years ago. It introduces this technique but doesn’t explain why. What does the standard say? There’re two places where private are allowed to be used outside its enclosing class,...

August 10, 2022 · Last updated on August 10, 2022 · 3 min