3 ms·
It's unfortunate that classes are always taught as if they were a structure with some functions attached. That is one way to implement it. But object orientat
by gumby 7y ago
It's unfortunate that classes are always taught as if they were a structure with some functions attached. That is one way to implement it. But object orientation is a philosophy or approach to abstraction, that's all.
But the array approach may may sense when some of the data are infrequently used. For example you could have a bunch of objects with people's names, ages addresses and favorite food. You may frequently manipulate or examine those names, ages and food preferences but only occasionally need the address. Your accessors _name, _age, and _pref may look at an instance variable while _address could look into the array.