Suppose I have this code. Your basic "if the caller doesn't provide a value, calculate value" scenario.
void fun(const char* ptr = NULL)
{
if (ptr==NULL) {
// calculate what ptr value should be
}
// now handle ptr normally
}
and call this with either
fun(); // don't know the value yet, let fun work it out
or
fun(something); // use this value
However, as it turns out, ptr can have all kinds of values, including NULL, so I can't use NULL as a signal that the caller doesn't provide ptr.
So I'm not sure what default value to give ptr now instead of NULL. What magic value can I use? Does anybody have ideas?