c++ function taking function pointer with a default function
assume I have the following function
int watchVar(const char* var, const char* descriptor,
Color (*colorfunc)(const char* var) = yellowColorFunc)
with
Color yellowColorFunc(const void* var){
return Color::yellow();
}
I want to overload watchVar but do not want to create a default color
function for each type.
g++ won't compile it. :/
Is there another way besides declaring colorfunc to take a void pointer
and forcing the caller to cast the argument later himself?
Thanks
No comments:
Post a Comment