Hmm, I read a few guides on this, but I can't figure it out, how to use function pointers in C ++ correctly?
I have a class that I want to call a function after it has finished everything that it is doing at the moment, for example:
class WindowImages
{
public:
void Update()
{
for(unsigned int i = 0; i < _images.size(); i++)
{
_images[i]->MyFunctionPointer();
}
}
void Add(Image* image, void (*func)(void))
{
image->function = func;
_images.push_back(image);
}
private:
vector<Image*> _images;
}
class Image
{
public:
void ImageClicked();
void *function(void);
};
void main()
{
Image* image = new Image();
WindowImages images;
images.Add(image, image->ImageClicked);
}
I'm trying to add an image to a vector and pass a function as an argument that will be called when the image class finishes doing everything it needs to do with each image. The functions will be different for each image, but they will all be in the void function () format .
, , ?
, ... , ( , , ++ 11 lambdas), !