Using a Loop to Call a Function From Class Objects Stored in a Dynamic Array

I am writing a code that utilizes a dynamic array to store objects of a class with various functions and variables. Let's say that I wanted to make a loop to call a function for each object in the array. How would I do that? I cannot just say something like object1.function() because i need to be able to call the function from each object in the array. I have also tried something like array[0].function(), but this always ends up in getting wrong values for the member variables in the function. There must be something that I have yet to learn which will save this code.

Here is a code fragment just to help demonstrate what I'm talking of.
 className array[0] = object1; //array[1] = object2 and so on...
 for (int i = 0; i < 5; i++)
      object1.function(); //Will only call function for object1 but with correct values
      array[i].function(); //Variables in the function get wrong values
array[i].function() is right, your other logic must be off
Topic archived. No new replies allowed.