i have a question regaring c++ and arrays.
let say i have a class which is called CustomArray, and is nothing more than an generic array wich has attributes for size and capacity, to make the array dynamic. defined as:
template<typename T>
class CustomArray
{
public:
int capacity, size;
T* items;
//constructor
//destructor
//function1
//function2
//etc...
};
now i'm kinda stuck, i want to implement a function like:"
void performOnAllItems(/*function?*/)
{
for(int i = 0; i < size; i++)
{
//perform function on element
}
}
that takes another function as a parameter (if that is possible?) and performs it on all elements. is that possible? and if so... how?
thanks in advance.