Call function with same name for every object

I have about 12 classes, with a variable number of objects each.
they all have a function called update()

is there a way to call update for every class without writing it all out manually like this:

1
2
3
objectone.update();
objecttwo.update();
...


I would prefer to do something like this:

1
2
3
4
for(const objects& object : everyobject)
{
     object.update();
}
Hi,
You might want to show your code to prove that manually calling update() for a large number of objects is long & problematic. After that, we will analyze your code and give you the best approach to suit your needs.
s there a way to call update for every class without writing it all out manually like this:

Presumably you mean "every object."

Are these objects in a container? Do the classes share a common base?
Put them in a container, iterate through the container, and call update() in each iteration.
Topic archived. No new replies allowed.