←back to thread

218 points signa11 | 1 comments | | HN request time: 0s | source
Show context
throwaway7894 ◴[] No.43681266[source]
As someone who has a file with similar hacks, I will say this: I am not a C++ fan, but if you find yourself writing C code where you simulate methods via structs with function pointers often, just use C++ as a basic "C with classes" at that point. You want methods anyway, you have to go through a pointer dereference to call the function, it's just not worth the code weirdness. If you have the grit to use structs with function pointers everywhere, you have the grit to stick to the simpler subset of C++.
replies(5): >>43683169 #>>43683849 #>>43684044 #>>43701516 #>>43703558 #
codr7 ◴[] No.43684044[source]
Nope, not from my experience.

Because in C++ the features are just there right around the corner, they will seep into the code base.

And I don't want even classes, there's too much junk in there that I don't need.

replies(1): >>43701718 #
ryao ◴[] No.43701718[source]
Can you think of anything I missed:

https://news.ycombinator.com/item?id=43701516

replies(1): >>43701845 #
1. codr7 ◴[] No.43701845[source]
offsetof/baseof springs to mind, for intrusive stuff.

You can sort of emulate it using pointers to member but it quickly loses its appeal.