5 ms·
The C++ access restrictions exist solely to teach and enforce proper API usage by other developers. They're supposed to trigger a reconsideration of the API wh
by bdowling 7y ago
The C++ access restrictions exist solely to teach and enforce proper API usage by other developers.
They're supposed to trigger a reconsideration of the API when a new developer runs into a restriction, but more often in my experience the new developer will just add a new public interface.
- kazinator 7y agoAnd you can add yourself a public interface even if all you have is a compiled library, and header files. Flipping a "private:" to "public:" has no effect on the binary compatibility.
- slavik81 7y ago> Flipping a "private:" to "public:" has no effect on the binary compatibility. That's not the case on Windows. The access qualifier is part of the mangled name. https://en.wikiversity.org/wiki/Visual_C%2B%2B_name_mangling#Basic_Structure https://en.wikiversity.org/wiki/Visual_C%2B%2B_name_mangling...
- kazinator 7y agoThat shouldn't prevent the subversion of data members or inline functions, or the ability to add your own member functions to the class.
- bdowling 7y agoIt's still an honor system. There's a way to generate code that will call the "private" or "protected" data/function even if it violates what's specified in the headers.
- dearrifling 7y agoIt can change the "POD for the purpose of layout" status of a class on Itanium. It can change layout.
- vnorilo 7y agoBecause Badge is a template, this will produce a linker error (duplicate symbols). Of course you can get around if you really, really want to. But I think this subthread is starting to split hairs.