5 ms·
Plus if you don't need inheritance, you can just use pointers to structs and pass them to functions. And if you need simple polymorphism in some small places, y
by sdegutis 10y ago
Plus if you don't need inheritance, you can just use pointers to structs and pass them to functions. And if you need simple polymorphism in some small places, you can use tagged unions.
- jdmichal 10y agoThis viewpoint is exactly why I like Rust. It has syntactic sugar to make things look like traditional objects, but everything is really a bundle of data with a set of associated static functions. (v-tables only appear with trait objects AFAIK, which are uncommon compared to templates.) And tagged unions are built in, with pattern-matching!