This is nice and simple. You can see we’ve declared and initialised the static variable at the top of the file. We increment it in the code, and then we output that variable to see that it has changed accordingly. You can access this variable from anywhere in this file. If you defined functions here, they would also be able to see and share the static variable.
Now let’s look at another example.