3 ms·
That's how any C++ stuff of mine goes, "given the chance", ie. the self-contained, private/hobbyist stuff. With structs instead of classes you still have the co
by dualogy 3y ago
That's how any C++ stuff of mine goes, "given the chance", ie. the self-contained, private/hobbyist stuff. With structs instead of classes you still have the convenience of instance methods (rather than just mynamespace_funcname funcs), statics, even namespaces (hardly necessary with methods and statics), yet can avoid inheritance and the whole public/protected/private noise (public by default, otherwise structs and classes are exactly equivalent in C++) except for the rare case where it does seem beneficial over a simple field.
- rwbt 3y agoI also stopped writing destructors (because eventually that leads to writing move constructors); instead now just use a unique_ptr to wrap resources (covers most of the cases) or a simple scope_exit (ala "defer"). Turns out separating ownership and lifetime really helps to write much better C++ code for me. These simple rules coupled with great modern C++ syntax sugar like lambdas, tuples and 'auto' along with the basic data structures in it's standard library makes it a breeze.