+ 1

Static 🤯🤯

When I should to use "static"? Either in a variable or class and methods. I know how it works but I don't know when I should use it.

12th May 2022, 3:33 PM
Roberto Navarro
Roberto Navarro - avatar
1 Resposta
+ 4
A method is static if it does not depend on the object state. A variable in a class is static if it is shared among instances. A static variable/function outside any class (in C) is assembly local. If the variable is not needed / the function not called outside the assembly unit, it is static. By "is static" I mean is static in a formal sense and should be declared as such.
12th May 2022, 4:09 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar