Results 1 to 4 of 4

Thread: Static variable initialization

  1. #1
    Join Date
    Aug 2006
    Posts
    253

    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:

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    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.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    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.

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    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.

Similar Threads

  1. Servlet static variable
    By Sheenas in forum Software Development
    Replies: 5
    Last Post: 06-03-2010, 11:24 AM
  2. Replies: 2
    Last Post: 28-08-2009, 07:51 PM
  3. Is it possible to have static variable in python?
    By gvBlake in forum Software Development
    Replies: 2
    Last Post: 21-07-2009, 09:56 PM
  4. Replies: 3
    Last Post: 25-04-2009, 11:34 AM
  5. Can we use static variable in other programming languages
    By FlayoFish in forum Software Development
    Replies: 2
    Last Post: 25-04-2009, 10:56 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,153,717.15491 seconds with 17 queries