The keyword static
can probably be seen as somewhat "overloaded".
The following usage-options are all viable:
- Static local variables
- Static global variables
- Static member variables
- Static global functions
- Static member functions
Variables:
In terms of runtime, all types of static variables are essentially the same. They all reside in the data-section of the program, and their addresses remain constant throughout the execution of the program. So the only difference between them is during compilation, in the scope of declaration:
- Static local variable: recognized by the compiler only in the scope of the function
- Static global variable: recognized by the compiler only in the scope of the file
- Static member variable: recognized by the compiler only in the scope of the class
Functions:
In terms of runtime, all types of functions (static and non-static) are essentially the same. They all reside in the code-section of the program, and their addresses remain constant throughout the execution of the program. So the only difference between them is during compilation, in the scope of declaration:
- Static global function: recognized by the compiler only in the scope of the file
- Static member function: recognized by the compiler only in the scope of the class
As to your question, arguments are passed to a function in the stack. There is no sense in having them static
, because that would effectively place them in the data-section. And if they are located in the data-section, then the function can simply read them from there instead of having them passed to it in the stack.
static
making point here? I can say that its not making sense putting static. Can I say thatstatic
keyword does not matter in function parameter list? – Mustansar Saeed Mar 20 '14 at 18:22static
`. – barak manos Mar 20 '14 at 18:27