I have code in which classes inherit from a base class.
This base class has a function that, when launched, must call functions that will be executed by children. That is, the general algorithm is the same for all children, but the implementation of the steps should be different.
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 this, the following error message appears:
no matching function for call to 'mem_fun_ref(bool (Foo<int>::*)(int, int))'
Can someone give me some idea of what I have been doing for a long time?
source
share