I have class DB:
Code: Select all
class DB {
protected:
map<int, string> List;
public:
template <class C>
void ForEach(void (C::*callback)(int id));
};
(Note: MDB is a global instance of DB.)
Code: Select all
class test {
public:
void hi(int id) {
cout << "Hello " << id << "!" << endl;
}
test() {
MDB->ForEach<test>(hi);
}
};
int main(int argc, char *argv[]) {
test h;
}
Code: Select all
void DB::ForEach(void (C::*callback)(int id)) {
/*Do the loop, etc... */
}
Code: Select all
main.cc: In constructor ‘test::test()’:
main.cc:55: error: no matching function for call to ‘DB::ForEach(<unresolved overloaded function type>)’