I know how to make a function an input argument when the function isn't a method, but I can't figure out how to do it when the function is a method.
Here's what I tried:
#include <iostream>
class A
{
void funct_1(int a, void (A::*f)(int))
{
(A::*f)(a);
}
public:
void funct_2(int k)
{
// do something
}
void funct_3(int k)
{
// do something
}
void funct_4(int k)
{
// some reason to use the function argument functionality...
if (k % 2)
funct_1(k, funct_2);
else
funct_1(k, funct_3);
}
};
int main()
{
A a;
a.funct_4(4);
return 0;
}
The above code doesn't compile. I've tried lots of variations, but can't find any syntax use that works. Could someone explain what I'm doing wrong here in terms of the syntax?