I have written this piece of code:
namespace {
void SkipWhiteSpace(const char *&s) {
if (IsWhiteSpace(*s)) {
s++;
}
}
bool IsWhiteSpace(char c) {
return c == ' ' || c == '\t' || c == '\n';
}
} // namespace
The problem is that the compiler complains that IsWhiteSpace() was not declared in this scope. But why? Sure, the namespace is anonymous but still the functions lie within the same namespace, aren’t they?
Perhaps it’s because you’re defining
IsWhiteSpaceafterSkipWhiteSpace.Edit:
I successfully compiled the following code:
Moving
Function1aboveFunction2results in the error you mentioned. So, yes, it’s becauseSkipWhiteSpacehas no knowledge ofIsWhiteSpace. You can solve this by declaring the functions ahead of time and then defining them normally afterwards, like this: