- Part 1: Variables and Data Types
- Part 2: Arrays
- Part 3: Functions
- Part 4: Conditional Statements
- Part 5: Looping
- Part 6: Pointers
- Part 7: Objects
- Part 8: Complex Data Types
When thinking in the object-oriented paradigm, there is often a need to share values across different object instances. When creating new ones, there will always been a single value that all can access and use. The keyword static helps with this.
Any variable or function defined as static will be defined once for all objects.
However, while the use of static will define it (allocate memory for it, in most cases), it must be given a value outside of it.
Instances and Shared Values
Normally, each new object has its own memory and values. With using the keyword static, values can be shared across all of them.