Hacker News new | ask | show | jobs
by alex_smart 904 days ago
The biggest advantage of C-style polymorphism vs, say, C++ is that it actually offers much better encapsulation.

Having private methods declared in the header file which is supposed to be the public contract for the class is such an anti-pattern. And the usual solutions offered for this problem are ugly in their own right (*pImpl).

I only properly learnt to appreciate the power and beauty of OOP by reading people’s C code.

1 comments

Which C++ modules fix.

Plus that same C pattern compiles in C++ without problems.

C++ modules sound incredibly hard to use.
Yeah, for GCC users, or the folks stuck in compilers outside the big three, still catching up to C++17.

VC++ and clang 17 mostly works now.