I'm pretty new to c++ but I'm trying to port over a flash game I've started. I'm stuck trying to pass a function in as a parameter, and then set a property equal to that function.
class Param
{
private:
float function();
float value;
public:
Param(float (func)());
Param(float (func)(), float value);
~Param();
void update();
};
I've tried something like:
Param::Param(float (func)()) {
this.function = func;
}
But it doesn't seem to like that. I'm not sure if it needs to be a pointer either, I'd like to just specify it when the Param
is instantiated rather than pass a reference that might get deleted to it.
EDIT: If someone could also answer, is there a way to make these passed in functions optional? As in a function for it to default to if none is specified?