filipe (835):
A static function is only known in the file it was declared. It's used a lot in C because there's no namespaces and no classes.
What do you mean in the file it was declared.is that mean if i create a header file and declare a static function in it, i wouldn't be able to use it in the source file or what?
Can you explain it more simpler and with more details?
If you insert a definition along with the declaration into a header file, it will define a separate function inside all the translation units that use it (translation unit = .cpp + all its #includes).
Static functions are typically meant to be local to a .cpp file.
A static global function won't be visible when linking with other source files
This feature is deprecated in C++ and unnamed namespaces should be used instead:
1 2 3 4
namespace
{
int GetNumberOfPages() { /*...*/ } // same effect, the C++ way
}