answersLogoWhite

0

S

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Why there are no global variables in java?

Global variables are globally accessible. Java does not support globally accessible variables due to following reasons:The global variables breaks the referential transparencyGlobal variables creates collisions in namespac


Do threads share global variables?

No, threads do not share global variables by default. Each thread has its own copy of global variables, which means changes made to global variables in one thread do not affect the values in other threads.


What is the other name of global variables?

Another name of global variable is "EXTERNAL VARIABLES".


What are global variable?

Variables that are declared globally outside every program are called global variables.


What is a logical use for global variables?

Storing global data.


What are the differences between global variables and local variables in C plus plus?

Global variables can be seen in all blocks of your program, when local variables are visible only within the block where it's declared.


Is global variables are stored in registers?

They is not.


Can global variables be called preprocessors?

No.


What are the disadvantages of variables?

The only disadvantage of a global variable is that you cannot directly encapsulate them. Other than that, there is no real disadvantage of global variables.


Are C variables initialized to 0 by default?

Only global/static variables are, local variables aren't.


What is the syntax of global variable in java?

There's no global variables in Java.


What are the five advantages and five disadvantages of using global variables?

The only case where a global variable is advantageous is when that global is a constant variable and it represents a truly global concept. The value of PI, for instance, is a truly global concept and it has a constant value. The exchange rate between dollars and Sterling is also a truly global concept, but it is non-constant and should not be declared global. Global (non-constant) variables are problematic because it can be difficult to track down all the places that interact with a global, especially if the global has external linkage. Even if that is not a problem in itself, a global cannot cater for both single-threaded and multi-threaded applications. If intended purely for single-threaded applications then there will be no synchronisation mechanism, thus it cannot be used in a multi-threaded application as this could lead to a data race. Conversely, if intended purely for multi-threaded applications, it will have a synchronisation mechanism but this could lead to performance issues on single-threaded applications where synchronisation is not required. In trivial applications, global variables can often be useful because the scope of a global can be well-defined. But in non-trivial applications, it becomes more difficult to limit the scope of a global. One way to limit the scope is to declare the global variable static, thus limiting its scope to the translation unit in which it is declared (static global variables cannot have external linkage). However, by limiting the scope, the variable is no longer a truly global concept.