August 2012
Intermediate to advanced
976 pages
30h 17m
English
As usual, when we use an overloaded function, the context must make it clear which version is being used. When we declare a pointer to an overloaded function
void ff(int*);void ff(unsigned int);void (*pf1)(unsigned int) = ff; // pf1 points to ff(unsigned)
the compiler uses the type of the pointer to determine which overloaded function to use. The type of the pointer must match one of the overloaded functions exactly:
void (*pf2)(int) = ff; // error: no ff with a matching parameter listdouble (*pf3)(int*) = ff; // error: return type of ff and pf3 don't match
Read now
Unlock full access