What is a “static” function in C?

前端 未结 12 1134
野的像风
野的像风 2020-11-22 16:03

The question was about plain c functions, not c++ static methods, as clarified in comments.

I understand what a static variable is, but wha

12条回答
  •  孤城傲影
    2020-11-22 16:15

    static functions are functions that are only visible to other functions in the same file (more precisely the same translation unit).

    EDIT: For those who thought, that the author of the questions meant a 'class method': As the question is tagged C he means a plain old C function. For (C++/Java/...) class methods, static means that this method can be called on the class itself, no instance of that class necessary.

提交回复
热议问题