I have this problem: A class of mine has a function called f. Some member function needs to call a global function called f. Now that's impossible, as I understand. To reach the global function from the class I need to call it under another name. How can I assign another name to it?
Do synonyms exist in C++ ? To define a preprocessor symbol doesn't work here: The names must be different AFTER preprocessing. So I have this global function:
double f(double x)
{
return x;
}
I could of course write another copy of the function with another name:
double f_(double x)
{
return x;
}
but that's ugly. An elegant solution, please. I'm thinking about defining a global function pointer:
double (*f_)(double x) = &f;
or an inline wrapper function:
inline double f_(double x)
{
return f(x);
}
But these are not truly synonyms. Is there a nicer way?