Is it possible to go through all the objects in a class/structure and change their variables without using the names of all the objects?

Let's say I have a class/structure, fruit, with 500 objects:
Apple
498 objects
Cherry

With integers:
Yum
Size

If I wanted to change all their yums based on their size, that would require me to do something like:
Code:
Apple.yum*=size
Strawberry.yum*=size
...
Cherry.yum*=size
And that is way too much typing.




I've tried using a pointer to apple and then increasing it by 1. That seems to only work in arrays.
Yes, I am aware I could just make a giant array.

I have asked several people this question. Is it even possible?