If I have two classes like this :
class A
{
public:
int *(*fun)( const int &t );
A( int *( *f )( const int &t ) ) : fun( f ) {}
};
class B
{
private:
float r;
int *f(const int &t)
{
return new int( int( r ) + t );
}
A a;
B() : a( A( f ) ) {}
};
This results in compiler error.
I want to assign f
to a
's function pointer.
The thing is that A
can be used by many classes not just B
so I can't simply define fun
as B::*fun
.
None of the posts I've found on the internet and here on stackoverflow address the issue of using the function pointers with many classes each having its own member function but the same prototype.
So what to do?