+ 3

How to assign a pointer to function?

we define a pointer to function using typedef keyword. we define a function with deafault argument and return type with define keyword and name as pointer

3rd Mar 2017, 7:34 AM
jolly
jolly - avatar
1 Resposta
0
//c++ hash table function pointer //function int hash(const Obj & obj){ return obj.value%n; } //hash table dec. ht<dataType> mTable(hash, n); //private members in ht ADT<ADT<dataType> > table; int(*hashfun)(const dataType &); //constructor ht<dataType>::ht(int(*hf)(const dataType &), int s):table(s){ hashfun = hf; } hope this helps!
3rd Mar 2017, 8:24 AM
Michael Szczepanski
Michael Szczepanski - avatar