Re:Abstraction without overhead: traits in Rust
by marrs on Tuesday May 12, 2015 @08:15AM
(#9531132)
JS is a bad example because people who do that are preferring inheritance to composition, which is absurd.
In the case of C, yes you can do that, and where performance is critical you might prefer to do it, but it's obviously not going to be your first choice if you have any sense.
Sure you can, for some value of base class and cast. You might not be able to use particular keywords, but data is data and math is math. You might not be able to use the built-in type system to do it.
C and javascript programmers write their own inheritance-based type systems all the time. And anything you can do in C, you can do in C++ if you really want to.