static

using static property of an abstract class inside a generic class that works on subclasses of the abstract class

Hi, I have a question regarding the following code: abstract class a { public static string x; } class b<c> where c : a { public void f() { c.x=10; } } This code does not compile. I get an error at the statement c.x=10; . The problem makes it look as if the condition where c:a does not have any effect at all...

Dynamically load assemly in static constructor

I have read the following code: public class DalFactory { private static IDataContext _instance = null; static DalFactory() { string asm = ConfigurationManager.AppSettings["DAL-Assembly"]; string cls = ConfigurationManager.AppSettings["DAL-Type"]; Assembly a = Assembly.L...

Static properties in C++

With pseudo code like this: class FooBar { public: int property; static int m_static; } FooBar instance1 = new FooBar(); FooBar instance2 = new FooBar(); If I set property of instance1, it would obviously not effect the second one. However, if I set the static property instead, the change should propagate to every instance of...

Weird linker error with static std::map

Why do I get linker error when I try to compile this in Visual Studio 2008 #include <stdafx.h> #include <iostream> #include <map> #include <string> class MyClass { public: MyClass () { }; virtual ~MyClass() {}; static std::string niceString (std::map<int, int> mappp) { _myMap = mappp; return "nice string"; }; private: static std:...

Why is my constructor being called over and over?

I've got the following h file: #ifndef GLOBAL_DATA_H_ #define GLOBAL_DATA_H_ class GlobalData { public: GlobalData(); ... private: ... }; namespace global_data { static GlobalData globalDataInstance; } #endif Countless files include the header file above, and access global_data::globalDataInstance. If I put a bre...

Prohibit an Instance from calling Shared/Static Method?

Is it possible to prohibit an instance of a class from calling a shared/static method? For example: I want to allow this: ClassName.MethodOne() But I want to disallow this: Dim A As New ClassName A.MethodOne() The reason this is desirable is that in this case it is semantically confusing if an instance can call the method. ...

Which technology should be used for serving large number of static files?

My main aim is to serve large number of XML files ( > 1bn each <1kb) via web server. Files can be considered as staic as those will be modified by external code, in relatively very low frequency (about 50k updates per day). Files will be requested in high frequency (>30 req/sec). Current suggestion from my team is to create a dedicated ...

C++: Best way to destruct static stuff

Hi, When I have a class containing static stuff, how can I free the memory at the end of the application the best way? Foo.h class GLUtesselator; class Foo { private: static GLUtesselator *tess; public: Foo(); virtual ~Foo(); } Foo.cpp #include "Foo.h" #include <GL/glu.h> GLUtesselator *Foo::tess = gluNewTess(); // S...

What kind of role does static class play in web application?

Hi all, if I have the following class, will I run into a problem if 100 people are requesting the page at the same time? If there is only one copy of UpdateUser, will all the requests have to queue up and wait for their turns? Thank you. public static UserManager { public static void UpdateUser(int UserID) { // this...

Static method Causes problem

Dear all, I have a static method as following: public static void writeArticle(TypeA typeA, TypeB typeB) { AWriter writer = AFactory.getWriter("aWriter"); Article article = writer.newArticle(); /* PARAMETER WRITE START */ article.set("title", typeA.getTitle()); article.set("author", typeB.getName()); article.set("age", t...

Pattern for C-style static variables in Java?

What is the best way to create a C-style static variable in Java (local to a method)? I have a method in which I need to calculate a variable only once, and do not need to recalculate it for the lifetime of the object. I understand that I could create a final field, but this variable may not be required in all cases and would only be r...

How Windows Static Control Prevent Input Focus

We know that Static Control in Windows does not receive input focus. But since Static Control in Windows is just a child window, according to what I understand so far, any window should be given input focus when we click on it. So how does Static control achieve this effect of rejecting input focus? I suspect it has special processing ...

Java Static confusion

I'm working with Java; I have worked with C++ before. I am thinking about static usage in Java. If I create static methods and variables in the class, Why can I access them through the object also? Example: class Test{ static int count=0; int id; static void updatec(){ count++ } } class TestMain { public static void m...

Corrupted singleton data using CxxTest

This is a weird problem and I'm not sure what to make of it. I have something like the following: struct Parms { const std::string value1; const std::string value2; std::string parm1; std::string parm2; Parms() : parm1(value1), parm2(value1) {} static const Parms& getDefaults() { static Parms defa...

Static char array not found and not working with strncpy?

char * function decode time() { tm *ptm; //time structure static char timeString[STRLEN]; //hold string from asctime() ptm = gmtime( (const time_t *)&ltime ); //fill in time structure with ltime if(ptm) { strncpy(timeString, asctime( ptm ), sizeof(timeString) ); //EDIT sprintf(test, "Sting is: %s", tim...

EF 4.0 model caching the data, and does not detect the modified data.

Dear All, I am developing ASP.NET application and I have problem with the EF 4.0 model. The EF model detects the newly added and deleted data, but not the modified data from the database. Here is an example of the problem what I have. A- Database: Script to generate the "Employees" database table CREATE TABLE [dbo].[Employees] ( ...

Best Static Photo Gallery Generator

There are a lot of static website generators out there, but most of them seem rather text-oriented (to my knowledge). What are the best image gallery static website generators? ( Note: I realize that a more general form of this question has been already been asked. I think this question is different enough to stand on its own. ) ...

iPhone Static Library for iOS3 and iOS4

Hi I'm trying to build a universal binary from a static library that works for both ios4 and ios3. However, when I add the library built in ios4 and try to use it in ios3 it gives me these kinds of errors: Undefined symbols: "_OBJC_CLASS_$_NSMutableCharacterSet", referenced from: objc-class-ref-to-NSMutableCharacterSet in myL...

Multithreading on Static Methods/Classes

Do We really need Locking for Static methods(Static Class) when the methods are heavily used by threads? Is it required when Static methods are using resources like SQL Queries/StoredProcedures ? Thanks Pankaj ...

Static Variables Behaviour in a Java Servlet

Hi, I am developing a java servlet that while running, starts different objects methods in new threads. Those threads should access a variable that describes the specific servlet instance, say jobId. For this reason, i declared the jobId variable as static. The servlet constructor is calculating this value for each servlet instance (call...