Static variable initialization
I know how to initialize a static variable. My variable is a structure, I know initialize a variable type int, double, etc. .. But not a structure.
I use a class and I want my obj1 variable to static so that it is common to all objects :
Code:
class Position (
private:
static object
public:
Re: Static variable initialization
You can initialize the value of a static local variable as part of its declaration.The initial values of global and static variables are stored in ROM in a segment called ?C_INITSEG. If you declare an array to be Static, you can initialize its rank (number of dimensions), the length of each dimension, and the values of the individual elements.
Re: Static variable initialization
In computer programming, a static variable is a variable that has been allocated statically — whose lifetime extends across the entire run of the program.Variables defined local to a function disappear at the end of the function scope. So when we call the function again, storage for variables is created and values are reinitialized. This is in contrast to the more ephemeral automatic variables, whose storage is allocated and deallocated on the call stack; and in contrast to objects whose storage is dynamically allocated.
Re: Static variable initialization
A static variable, also referred to as a class variable, is a variable which exists across instances of a class.You can declare static variables with the same name in more than one procedure. A static object of class type will use the default constructor if you do not initialize it. Automatic and register variables that are not initialized will have undefined values.If you do this, the Visual Basic compiler considers each such variable to be a separate element. The opposite of a static variable is an instance variable, which is a variable related to a single instance of a class.