We can have function declarations inside of function bodies:
void f(double) {
cout << "f(double) called";
}
void f(int) {
cout << "f(int) called";
}
void g() {
void f(double); //Functions declared in non-namespace scopes do not overload
f(1); //Therefore, f(1) will call f(double)
}
This can be done in order to hide a function such as f(int) in this case, but my question is: Is this really the only reason why it is possible to declare a function inside of another?
Or in other words: Does the possibility of declaring a function inside of a function exist for the sole purpose of hiding a function?