TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

For C programmers that hate C++

2 pointsby furconitover 11 years ago

1 comment

magnusjonssonover 11 years ago
Hmm, the C code and C++ code aren&#x27;t even solving the same problem, and they aren&#x27;t using the same data structures. C++ uses inheritance while C uses a union, for no good reason. What in C++ is struct A : B { } is in C struct A { struct B b; }, not some weird union. Of course unions are not type safe.<p>And in practice, you can come close to the template solution with a macro for the loop. Sure, it will be a little more explicit about which functions are being called, but that&#x27;s not a bad thing in my book. And, as with the C++, you&#x27;ll have to build up the equivalent scaffolding and associated code, which I notice is conveniently left out of the C++ examples.h