473,327 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Info on Static Variables Needed by SHIKHAR

HI,
Could anyone please tell me what are static variables and what exactly
are there features.
I am a little bit confused.

Thank You

Jul 23 '05 #1
2 1839
<ka*******@yahoo.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
HI,
Could anyone please tell me what are static variables and what exactly
are there features.
I am a little bit confused.


Object names qualified with the keyword 'static'
are give 'static storage duration', that is, they
have a lifetime equal to that of the program's
execution. 'static' objects are also default-
initialized if no explicit initial value is
given.

Which C++ book(s) are you reading which don't
explain this?

-Mike
Jul 23 '05 #2
On 8 Jun 2005 11:32:57 -0700, ka*******@yahoo.com wrote:
HI,
Could anyone please tell me what are static variables and what exactly
are there features.
I am a little bit confused.


There are static member variables, local static variables inside a
function definition, and global static variables at file scope.

In a nutshell, storage for static member variables is allocated
independently of any object of the class of which they are a member.
They must be initialized outside of the class definition (i.e. at
global scope).

Inside the body of a function definition, storage for a static
variable is allocated before the program runs. The value of such a
variable remains persistent beyond the scope of the function being
called. The initialization of such function static variables is done
before the function is called the first time -- sometimes well before,
but sometimes only at the last moment. I believe this is
implementation defined (please someone correct me if I'm mistaken,
don't have time right now to look it up...).

Variables declared globally outside a class or function body with the
keyword "static" are only visible at file scope in the translation
unit in which they are defined. IOW, you can have multiple variables
with the same name if they are all declared with the keyword "static"
and there is only one per translation unit.

--
Bob Hairgrove
No**********@Home.com
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: James | last post by:
Hello Java NG, I not sure if this is the right NG for this type of question but if not please let me know which is, TIA Any way first off let me say I'm a student and this WAS last weeks lab,...
7
by: BCC | last post by:
Hi, I have a class with several member variables that should be initialized according to user input before an object is instantiated. Using a static variable is required here. But, I would...
9
by: Bryan Parkoff | last post by:
I have noticed that C programmers put static keyword beside global variable and global functions in C source codes. I believe that it is not necessary and it is not the practice in C++. Static...
25
by: Sahil Malik [MVP] | last post by:
So here's a rather simple question. Say in an ASP.NET application, I wish to share common constants as static variables in global.asax (I know there's web.config bla bla .. but lets just say I...
28
by: Dennis | last post by:
I have a function which is called from a loop many times. In that function, I use three variables as counters and for other purposes. I can either use DIM for declaring the variables or Static. ...
5
by: katekukku | last post by:
HI, I need the source code for a programme in C. It should have the basic features of a paint programme like circle, line etc, etc,. I lost a programme which wa driven by keyboard, if somebody...
18
by: Jack | last post by:
Thanks.
9
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang...
12
by: sergey.lukoshkin | last post by:
Hello everyone! My task is in converting numbers from string to int variables. I used istringstream to perform it. So I wrote simple test function. But it doesn't work as I expected because...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.