static

static event handlers, threading and the like

Hi can anyone explain to me what is happening when a instance of a class declaring a static eventhandler will hold reference to other classes that have registered intent with the event handler in question, being that they are all static would there be any contention between users sessions(I mean his/her usage of the system in a point in...

How is a dynamically-typed language implemented on top of a statically-typed language?

I've only recently come to really grasp the difference between static and dynamic typing, by starting off with C++, and moving into Python and JavaScript. What I don't understand is how a dynamically-typed language (e.g. Python) can be implemented on top of a statically-typed language (e.g. C). I seem to remember reading something about ...

"Member modifier 'static' must precede the member type and name" Error C#

I am building a game of BlackJack and the main class for it is having a problem. This is my code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public class blackjack { static string[] playercards = new string[11]; ...

is static variable in c re-allocated everytime calling a function?

Suppose I have a static variable declared inside a function in c. If I call that function multiple times, does the static variable get re-allocated in memory every time the function call? If it does, why the last value can always be maintained? Example: void add() { static int x = 1; x++; printf("%d\n",x); } int main() { ...

how to link to static library in c?

I use code::blocks to compile my static library. The output result is a libstatic.a file. Now, how do I link to my library to use functions that were compiled? (I tried to use #include "libstatic.a" but my project doesn't compile) ...

file scope and static floats

Hello there. I've run into an interesting problem in an AI project of mine. I'm trying to format some debug text and something strange is happening. Here's a block of code: float ratio = 1.0f / TIME_MOD; TIME_MOD is a static float, declared in a separate file. This value is modified based off of user input in another class (I hav...

How to add a .o on a static library with Eclipse ?

I have a .h and a .o that I need to add to a static library in Eclipse. I'm able to add it to an application with the Linker options, but for a static library, I haven't found where to add it in the settings. ...

[PHP] Is there an equivalent to $this for static classes? ( kind of super but for the current class where it is used )

I know it wouldn't be exactly equivalent to $this, but is there a way to reference a static class from within itself without using the name of the class itself? ( like super but for itself ) This is just a way to avoid having to refactor all the class references if the class is renamed. Example: class foo { function bar() { static_this...

Variably modified array at file scope

I want to create a constant static array to be used throughout my Objective-C implementation file similar to something like this at the top level of my ".m" file: static const int NUM_TYPES = 4; static int types[NUM_TYPES] = { 1, 2, 3, 4 }; I plan on using NUM_TYPES later on in the file so I wanted to put it in a variable. ...

How should C++ methods that manipulate static data members be defined?

I have a C++ class which contains only static data members. I noticed the compiler is OK if I define the access methods as const, as static, or as "regular" - so all seem to work. My question is what is the correct/better practice in this case? Thanks! ...

Java: unable to access static singleton method

hi. i am facing one problem.i have a class named "ReportingService" and it should be singleton and is is extending "CommonService". package MyApp.Services.ReportingService; public class ReportingService extends CommonService { private static ReportingService instance = null; public static ReportingService getInstance() { ...

Asp.net Static Variable Life time Across Refresh and PostBack

Hi WorkAround: I have declared a class level Public static variable and initialized with a value 0 in the environment of ASP.NET 3.5 In load event I Incremented by 1 of that variable Problem: 1).After getting page refresh and even Postback, I am getting latest values of that variable. A variable declared as STATIC , not getting rese...

Is the following utility class thread-safe?

First let's look at the utility class (most javadoc has been removed to simply the example): public class ApplicationContextUtils { /** * The application context; care should be taken to ensure that 1) this * variable is assigned exactly once (in the * {@link #setContext(ApplicationContext)} method, 2) the context is...

Are there other languages besides D with static if?

I think D's static if is an interesting language feature. That prompts my question: Are there are other examples of compiled languages in which the compiler has a strong notion of the code and there are languages facilities to access them? For example, this code provides something similar to repr from Python: char[] repr(T)(T value) { ...

static member variable and method

If I have a C++ class which contains a static member variable, does the accessor method for this variable need to be static as well? Also, are there any issues that might occur if I inline this method? ...

Does C# resolve dependencies amongy static data member automatically?

If one static data member depends on another static data member, does C#/.NET guarantee the depended static member is initialized before the dependent member? For example, we have one class like below class Foo { public static string a = "abc"; public static string b = Foo.a + "def"; } When Foo.b is accessed, is it always "abcdef"...

Using a non-static class member inside a comparison function

Hello everyone, I'm currently developing a syntaxic analyser class that needs, at a point of the code, to sort structs holding info about operators. Each operator has a priority, which is user-defined through public member functions of my analyser class. Thus, when sorting, I need my sorting function to order elements based on the prior...

C# - Expose a Static Class inside a normal class?

Here is an easy example: ASP.NET provides several static classes based around the membership provider. We are forever using them in our pages. We also have a need to extend the base System.Web.UI.Page class. So, one thought we had was to expose the various static classes in our OurCompany.Web.UI.Page implementation. We cannot use a ...

problem w/ linking static function g++

Hi- I am trying to build a small program and I have my own library libfoo. I have a camera class that is calling a static function from my Vector3 class (i.e. crossProduct). My camera class and Vector3 class compile ok and are built into libfoo. However when I am linking like so: g++ -g -O2 -o test1 main.o -lfoo I get this: libfo...

How to configure routing for a java web app

Is there an easy way to rout all requests (except a few specific cases) for url "mysite/" to path "mysite/index.html?" Is it possible to do it only by editing web.xml file? ...