Static Data
Static Data
When is it good to use a static data type? I know what it is in a general programming sense, but in osdev whats the reason its used in alot of source code i see?
Re:Static Data
The only reason would be that you could use the same symbol name (for different symbols) in different modules and not have to think up a new clever name. Me on the other hand, I have a nameing scheme I follow that avoids the need for such things. A quick search of "static" in all my sources yeilded nothing but some stuff in comments.
In general programming though, there are very good reasons to use them. And in C++ static instanciation of classes can lead to some really cool factories and other clever things.
statics have there strongest use when you have many programmers working on the same project. This in general just protects them from one another - or if your project is rather large I guess it could protect you from yourself.
_mark()
In general programming though, there are very good reasons to use them. And in C++ static instanciation of classes can lead to some really cool factories and other clever things.
statics have there strongest use when you have many programmers working on the same project. This in general just protects them from one another - or if your project is rather large I guess it could protect you from yourself.
_mark()
Re:Static Data
The static keyword is used for several different purposes in C and C++:
static global functions and variables are private to that particular source file. Unless you have a strict naming convention, you should make any variable or function that is only used within that file static.
static local variables are similar to static global variables, except that they can only be used by the function where they are defined.
static class member functions and variables are similar to global functions and variables. Although they're declared within a class {} declaration, they aren't associated with a particular instance of the class and they can't access any non-static member functions or variables.
static global functions and variables are private to that particular source file. Unless you have a strict naming convention, you should make any variable or function that is only used within that file static.
static local variables are similar to static global variables, except that they can only be used by the function where they are defined.
static class member functions and variables are similar to global functions and variables. Although they're declared within a class {} declaration, they aren't associated with a particular instance of the class and they can't access any non-static member functions or variables.