473,473 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

local "static" variable

Hi,

Is there a way to define a local variable that retains it's value
between the function calls ?

Zeljko
Nov 15 '05 #1
3 1693
Is there a way to define a local variable that retains it's value
between the function calls ?


No, make it a field variable instead.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #2
Field = variable at class level.

And make it a public property to access it in a clean way.
In article <OQ**************@TK2MSFTNGP12.phx.gbl>,
ma********************@mvps.org says...
Is there a way to define a local variable that retains it's value
between the function calls ?


No, make it a field variable instead.

Mattias

Nov 15 '05 #3
Hm.. OK, I thought there might be something simlar to VB6 static
keyword.

On Wed, 12 Nov 2003 12:28:33 +0100, Mattias Sjögren
<ma********************@mvps.org> wrote:
Is there a way to define a local variable that retains it's value
between the function calls ?


No, make it a field variable instead.

Mattias


Nov 15 '05 #4

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

Similar topics

1
by: Richard Hayden | last post by:
Hi, I'm trying to port my O/S kernel from C to C++. I am using g++ with the following command-line switches: -Wall -fno-builtin -fno-rtti -fno-exceptions -fno-enforce-eh-specs -nostartfiles...
6
by: Kumar | last post by:
Hi, If i am using static variable in a function, in say a dll. If that dll is being used by a multi-threaded program, will the static variable be safe to use? I mean, will it have the problems...
3
by: Datta Patil | last post by:
Hi , #include<stdio.h> func(static int k) /* point2 : why this is not giving error */ { int i = 10 ; // static int j = &i ; /* point 1: this will give compile time error */ return k; } /*...
3
by: XPhaktor | last post by:
In C#, how do I replace using VB local static variable declarations to handle method reentrancy. Note, if you use a class-scope variable instead of a local one, then you run the risk of...
11
by: comp.lang.php | last post by:
function blah($item) { if (!isset($baseDir)) { static $baseDir = ''; $baseDir = $item; print_r("baseDir = $baseDir\n"); } $dirID = opendir($item); while (($fyl = readdir($dirID)) !== false)...
16
by: Chris | last post by:
Looking at some code I see a declaration inside a function like static const string s("some string"); Does the static serve any purpose here?
1
by: kiluyar | last post by:
I have such a function: class T { public: T(){...//some operations} }; T& GetInst()
14
by: Jess | last post by:
Hello, I learned that there are five kinds of static objects, namely 1. global objects 2. object defined in namespace scope 3. object declared static instead classes 4. objects declared...
2
by: auspicious | last post by:
Hi, I would like to know what does the standard say about initialization of local static variable's default initialization. void f(int a) { static int b; b+=a; }
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.