Hello. I currently am trying to implement a status effect system. I have several effects, each inheriting off a base effect (let’s call it baseEffect). I also have a status manager that will activate and deactivate each status as needed. What I am looking to do is have a function that takes in an index for the status that will be activated. I wanted to know if I can just create an array of baseEffect* and have them point to each child. For example:
/*
Assume I initialize an array of baseEffect* (called statusArray) and a bunch of child class pointers and then add said pointers to the array here
*/
myFunc(int8 statusIndex)
{
statusArray[statusIndex]->ActivateStatus();
}
Would doing the above call each child’s ActivateStatus function and perform the child’s function, or will I need to do a bunch of casting? If it is the latter, is there a way to do it more efficiently than just calling the same function for each object? Thanks in advance!