Alright, I'm not completely sure the best way to explain what I'm trying to do, as I'm trying to wrap my head around the concept.
I'm going to use an example that's from the Unity engine, which while it's kind of C# or Java if you want, I'm hoping that the concept is feasible in C++ too.
Basically, in the Unity engine I'd notice that scripts that are made have four main functions that are called automatically. Start(), Update(), LateUpdate() and FixedUpdate().
I don't have to go somewhere and type in MyClass.Update() for each time I create a new class.
Basically what I'm getting at is that it's kind of silly to have to do something like this:
1 2 3 4
|
MyClass.Update();
ThisClass.Update();
ThatClass.Update();
HisClass.Update();
|
Is there anyway using a loop or something to through every instance of a class that inherits from a class I'll just call ParentClass, then call their respective functions?
I'm sorry for the pseudo-code, but this will probably explain it better.
1 2 3 4
|
for(int i = 0; i < NumOfCurentParentClasses; i++)
{
ParentClass[i].Update();
}
|
I'm sorry I really wish I could explain this better, and I know I'm doing crappy job. I'm sure there's a name for this concept, I just don't know what it is.