Reputation: 2721
Suppose I have a header file like this
namespace a
{
static void fun();
}
and I have its definition in source file
namespace a
{
void fun()
{
}
}
This header file may be used in these files' own project or in several other projects. I get the the fun() function declared but not defined error. I don't understand why. But if I remove static from declaration, it works!
Upvotes: 0
Views: 1192
Reputation: 10857
The static keyword in this case means that the scope of the function fun() is limited to the file, i.e. it has the file scope. Removing the static, it has a global scope, but only within the namespace.
Upvotes: 6