I have an assignment about linked list and template where there are functions with strange parameters which are mandatory. I couldn't find online document about it and any provided materials are appreciated.
I have tried to assign op with another address and then it compiled just fine but I couldn't call it.
template <class T> struct L1Item {
T data;
L1Item<T> *pNext;
L1Item() : pNext(NULL) {}
L1Item(T &a) : data(a), pNext(NULL) {}
};
template <class T> class L1List {
L1Item<T> *_pHead; // The head pointer of linked list
size_t _size; // number of elements in this list
public:
void traverse(void (*op)(T &)) {
// TODO: Your code goes here
}
void traverse(void (*op)(T &, void *), void *pParam) {
// TODO: Your code goes here
// string *Req = static_cast<string *>(pParam);
// if (*Req == "find city's id") {
// op = this->_pHead;
// };
}
};