Storage classes are used to indicate duration and scope of a variable or identifier. Duration indicates the life span of a variable. Scope indicates the visibility of the variable. The static storage class is used to declare an identifier that is a local variable either to a function or a file and that exists and retains its value after control passes from where it was declared. This storage class has a duration that is permanent. A variable declared of this class retains its value from one call of the function to the next. The scope is local. A variable is known only by the function it is declared within or if declared globally in a file, it is known or seen only by the functions within that file. This storage class guarantees that declaration of the variable also initializes the variable to zero or all bits off. The extern storage class is used to declare a global variable that will be known to the functions in a file and capable of being known to all functions in a program. This storage class has a duration that is permanent. Any variable of this class retains its value until changed by another assignment. The scope is global. A variable can be known or seen by all functions within a program.
Chat with our AI personalities
extern variables are defined in different than the file where the main() is. extern variables can be accessed from other files. Static global variables are visible only within the file.
global means: defined here, available from everywhere
external means: defined elsewhere
Storage classes.
auto, extern, static, register, typedef (only formally)
AUTO EXTERN STATIC are the storage classes in c++
No such thing, pick one ot the three: static int x; extern int x; int x;
Different from what? Storage classes are auto, register, static, extern and typedef (formally).