Say, I have my calculateSalary() and it is able to print out each and every staff they have in the array. How can i implement a function to add all of the staff's salary together?
Because i have an array storing my staff objects which consist of derived classes.
Each objects have their fields like name, address, calculateSalary().
In this case u suggest i do a for loop to run through the array. But my array is defined in my base class.
I created a displayAllSalary() in my base class and derive class and my array is being defined in my main.cpp
Can i define another array in my base and derive class? Of same name to use it again?