I have a function
float addXPercent (float percent, ExampleClass* A, ExampleClass B, thisFunction) {
return (percent * B.thisFunction() + (*A).thisFunction());
}
and someFunction is a function that can be applied to both A and B like this
(*A).setSomething(0.4 * B.someFunction() + (*A).someFunction());
It takes a percent value like 0.4, applies it to the result of B.someFunction() and adds that value to the current value of A.someFunction().
What I want to do is generalize this part of the function out:
0.4 * B.someFunction() + (*A).someFunction()
into that addXPercent function. The result I expect to look something like this
(*A).setSomething( addXPercent (0.3, *A, B, thisFunction) );
I'm quite new to C++ so I did some googling and found out you can pass function to different function with the std header <functional>.
But I'm not sure how I'll pass a member function with syntax like this function< void () > thisFunction.
How should I go about doing that?
I wasn't able to find a related thread 1 2 (got Sorry, there were no post results for “”) so sorry if this is a duplicate question.