4 ms·
Encapsulation is done better and is easier to manage in C than it is C++.
by gp7 10y ago
Encapsulation is done better and is easier to manage in C than it is C++.
- ArkyBeagle 10y agoYes. I have entire code bases where the interface to a "capsule" ( because encapsulation, see :) is one function with void parameter and void return. Of course there's a central data store. But that's okay.
- nickpsecurity 10y agoThat's funny about capsules. More consistent when people discuss encapsulation, though. Far as OOP in C, it's definitely doable with quite a few approaches and even books dedicated to it. Example: https://www.cs.rit.edu/~ats/books/ooc.pdf https://www.cs.rit.edu/~ats/books/ooc.pdf Many think C++ with its benefits and problems are relevant to OOP in C but not entirely. That's because they think C++ was about adding OOP to C. It wasn't. Stroustrup used safe, OOP languages like Simula that he wanted more of. He intended to leverage C's popularity and tooling but transform it into something with benefits of other languages. So, the result is C-like but not quite C and complex. Just doing OOP in C, on other hand, is much easier and cleaner problem to solve. ;)