During the interview this afternoon, HR asked: What are the differences between static or static methods and non-static methods in C?
My answer is that static calls can be called directly instead of static ones that need to be instantiated. HR said that everyone knows this. What I ask is the essential difference.
I was depressed at the time. I only had 8 months of programming experience and almost never used static classes or methods. I only knew how to use them,
So I could only answer the question and asked a few questions later. The answer was unsatisfactory and the answer was rejected ..
After going home, I checked on the Internet and found that one needs to be instantiated and the other needs to be called directly. This is accepted as no problem. I will paste the rest.
For reference
Static is a class definition, and dynamic is an object definition.
Classes must be defined before objects can be defined. Therefore, static objects must be prior to dynamic objects, and only one static object can be created.
========================================================== ======
It is loaded once during static running.
Non-static operations are loaded every time
The static lifecycle is the same as that of the class.
========================================================== ========
Static variables and Methods belong to the class and are created when the class is called;
There is only one copy in the memory and will not increase with the increase of the object;
Dynamic variables and Methods belong to objects and will increase with the increase of objects.