4 ms·
Exactly! Ugh I hate that. "A cat can be an instance of animal, but it needs a 'meow' function" ... What?
by grahamburger 11y ago
Exactly! Ugh I hate that. "A cat can be an instance of animal, but it needs a 'meow' function" ... What?
- stephengillie 11y agoBy oversimplifying, these examples actually obscure the lesson. It helped me to think of OOP objects as sub-variables, or even as a set of variables grouped by the first part of their name. Like a "multi-key/multi-value" hash table. The purpose of functions only started making sense after learning calculus and the replacement method, where a complex term was replaced by a single variable. This is where I learned they're mostly for readability, an adaptation to make programming easier for humans to do.
- BatFastard 11y agoAdding a "meow" function is the wrong way to go about it. The base class just needs a protected sound function so that each derived class can set the sound in its initialization routine. So many programmers, so few who truly understand OOP.
- deleted 11y ago[deleted]