3 ms·
> First you add an extra function pointer for any member, even if it's not virtual Wrong. If some function is not virtual, there's no point to add it to vtable
by dimonomid 11y ago
> First you add an extra function pointer for any member, even if it's not virtual
Wrong. If some function is not virtual, there's no point to add it to vtable; so, it's just a regular function.
> Also the first technique doesn't feel like OO in any meaningful way.
Really? Of course I can be wrong, but for me, defining a state object and operate on it only through methods (i.e. functions that are given a pointer to state object) is exactly what is called an OO style.
- MichaelGG 11y agoThanks for the correction. I had misread and thought all functions were called with member syntax. I guess in simple cases like this the difference between OO and other styles are pointless. I'm just thinking that if I were to write it in a functional language, it'd probably a very similar API, though possibly/probably returning a new state vs modifying.