static non-member functions

Hello and thank you to any who will answer me. I tried googling before but I'm afraid I'm using the wrong keywords. My problem is I cannot understand the meaning of the static declaration in front of a function. I'm not meaning a member function, but rather a function present in the main cpp file. For example:

1
2
3
4
5
6
7
8
9
10
static void Myfunction (int arg1, double arg2, char arg3)
{
...
}

int main()
{
Myfunction (int a=1; double b=0.0, char c='x');
return 0;
}


what is the difference between declaring such a function as static instead to not to? I know how it works with member functions, but this is not a member of any class, is a simple function.
Hope someone will enlight me,
Bye
Last edited on
From http://www.cplusplus.com/forum/beginner/4758/

Answer by jsmith:
A static function inside a class is a function that can be called without an instance of the class.

A static function at file/namespace scope (ie, not within a class) within a .cpp file is a function whose symbol is not exported in the .o; that is, the function is not visible outside that .cpp file.

I assume the example in the original post is the latter case.
Thank you very much indeed! I'm sorry that the solution was already present inside the forum but I didn't know how to find it! :(
no problem :)
Topic archived. No new replies allowed.