static-variables

Access static class variable of parent class in Python

I have someting like this class A: __a = 0 def __init__(self): A.__a = A.__a + 1 def a(self): return A.__a class B(A): def __init__(self): # how can I access / modify A.__a here? A.__a = A.__a + 1 # does not work def a(self): return A.__a Can I access the __a class variable in B? It's possible writing a ...

Static variables in IIS-hosted web applications

If I declare a static field in a type instantiated within an ASP.NET application, hosted within IIS, is the same variable (i.e. same memory location) used by all of the worker threads used by IIS, opening up concurrency issues? ...

Should static properties in a Constants class implement backing fields?

I have a class Constants in which I store a number of static readonly variables. Should I do this: private static readonly int _maxThings = 100; ... public static int MaxThings { get { return _maxThings; } } That seems kind of redundant to me. Is there any reason why I wouldn't just do the following? public static int MaxThings { ge...

Class library and static variables in asp.net

I have class library which should encapsulates orm logic. To avoid some db calls, it should contain some kind of cache or static variables (I want to avoid them). It's used in asp.net and wcf applications. Since it's class library, I don't want to access Cache or other asp.net related stuff. I also want to avoid static vars because of th...

How do I declare a static variable inside the Main method?

Can we declare Static Variables inside Main method? Because I am getting an error message as "Illegal Start of Expression". Please reply. ...

Accessing Static Variable from child->child class php

I have the following setup: <?php class core { static $var1; } class parent extends core { function getStatic() { return parent::$var1; } } class child extends parent { function getStatic() { // I want to access core static var, how can i do it? //return parent::$var1; } } ?> I need to be able...

What exactly does "static" mean when declaring "global" variables in Java?

I've been running into this problem many times and I never bothered to learn why its happening and learn what "static" actually means. I just applied the change that Eclipse suggested and moved on. public class Member { // Global Variables int iNumVertices; int iNumEdges; public static void main(String[] args) { // do stuff ...

What exactly does "static" mean when declaring "global" variables in C++?

This is an expansion of the scope of a previous question of mine. What exactly is "static", how is it used, and what is the purpose of using "static" when dealing with C++? Thanks. ...

Static class members python

So I'm using static class members so I can share data between class methods and static methods of the same class (there will only be 1 instantiation of the class). I understand this fine, but I'm just wondering when the static members get initialized? Is it on import? On the first use of the class? Because I'm going to be calling the sta...

In C, does using static variables in a function make it faster?

My function will be called thousands of times. If i want to make it faster, will changing the local function variables to static be of any use? My logic behind this is that, because static variables are persistent between function calls, they are allocated only the first time, and thus, every subsequent call will not allocate memory for ...

Xcode linker and blocks: Undefined symbol "___block_global_1"

I am trying to build an application in Xcode 3.2.4 and am getting the following linker error: Undefined symbols: "___block_global_1", referenced from: ___block_holder_tmp_1.120 in foobarbaz.o ld: symbol(s) not found collect2: ld returned 1 exit status I'm at a loss to explain what I've done in my source file that might be caus...

Objective C - Static and global variable ???

In my .m file for a class named Ad , I have 3 static strings static NSSTring *AdStateDisabled = @"disable"; static NSSTring *AdStateExpired = @"expired"; static NSSTring *AdStateActive = @"active"; I can simply use these static variables in the current class, but i cannot call them from any other class, is there a way to make these st...

How to erase static variables in Android

I read this Article on StackOverflow. According to this, static variables will be erased, if the class is unloaded the JVM shuts down the process dies But how to destroy / to kill my application (application process) and so to erase all static variables programmatically from my application?! Thank you, Mur UPD These static varia...