3 ms·
For those accustomed to always using open source, the idea of hiding the implementation must seem odd. But consider the position of developer who implements a
by c-linkage 3y ago
For those accustomed to always using open source, the idea of hiding the implementation must seem odd.
But consider the position of developer who implements a shared library that is distributed in binary form only. In this case, the benefit of opaque pointers for the development of a library is that the implementation remains private at the source level. One could, of course, reverse-engineer the binary but few people would do it.
If you define your structures in a public header -- and this includes C++ classes and templates with private members -- one can easily see the implementation and, with a few casts, start munging the guts of your objects and baking in a hard requirement on a specific layout and / or version of your library.
- falcrist 3y agoOk I see what you're saying. Closed source libraries can make use of this idea.