I have some code where classes inherit from a base class.
That base class has a function which, when run, ought to call functions to be implemented by the children. That is, the general algorithm is the same for all children, but the implementation of the steps should vary.
template<class T>
class Foo
{
public:
Foo(T y):y(y) { for(int i; i < 10; ++i) x.push_back(i); };
protected:
virtual bool IsOk(T, int)=0;
void Run()
{
vector<int>::iterator it, bound;
for(int i; i < 10; ++i)
{
cout << "step " << i << endl;
bound = partition(x.begin(), x.end(), bind2nd(mem_fun_ref(&Foo<T>::IsOk), i));
for (it=x.begin(); it!=bound; ++it)
cout << " " << *it;
};
};
private:
vector<int>x;
T y;
};
class Bar : public Foo<int>
{
public:
Bar():Foo<int>(50){this->Run();};
bool IsOk(int x , int y) {return x == y;}
};
However, when I do so, I get the following error message :
no matching function for call to 'mem_fun_ref(bool (Foo<int>::*)(int, int))'
Could anyone provide me with some insight as to what I am doing wong?
Following are the prorotypes for
mem_fun_refYour
mem_fun_ref(bool (Foo<int>::*)(int, int))dosnt match any of these & hence the error.