Explain the meaning of static functions out of class in C++?

What is the use of static in a member function of a class and outside of class?
June 5th 19 at 21:16
1 answer
June 5th 19 at 21:18
The semantics is completely different. The scope of the static function is limited to the translation unit in which it is defined.
A kind of encapsulation in C.
ie in the class sees the same data out class the other ? data is available for the function - Pansy.Fe commented on June 5th 19 at 21:21
this does not apply to classes and their data - inherited functionality from C) Means, roughly speaking, that you can't call a function from another c/cpp file. - Elna.Volkman92 commented on June 5th 19 at 21:24
although, wait a minute, you mean use the staticmodifier to functions or local variables inside them? - Elna.Volkman92 commented on June 5th 19 at 21:27
kapets.... I Scope and this can not be in JS to understand. In C/C++ campaign is much more complicated in this regard. - Pansy.Fe commented on June 5th 19 at 21:30
i.e. for static functions out of class scope to the translation unit (file with *.c *.cpp) in another file in the project function is not visible. For static member functions class scope is limited to the class? - ruthie54 commented on June 5th 19 at 21:33
in JS everything is very bad in this regard. But, let/const and pointer functions these outrages are doing almost the same logical, as in other C-like languages.

In C++ everything is just easier, but it is best to learn is still through the sea, separating the wheat from the chaff. In C++ I like to reuse old keywords with a different meaning, as it still happened with the auto and const. - Elna.Volkman92 commented on June 5th 19 at 21:36
,
For static member functions class scope is limited to the class?

No, it is not limited. Here it only means that the member function has no this, so it can't be virtual and have access to only other static fields or member functions of a type. - Elna.Volkman92 commented on June 5th 19 at 21:39

Find more questions by tags C++