ASP.NET Application state vs a Static object

From: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312607 ASP.NET includes application state primarily for compatibility with classic ASP so that it is easier to migrate existing applications to ASP.NET. It is recommended that you store data in static members of the application class instead of in the Application object. This increases performance because you can access a static variable faster than … Read more

static vs extern “C”/”C++”

Yes, you are just lucky 🙂 The extern “C” is one language linkage for the C language that every C++ compiler has to support, beside extern “C++” which is the default. Compilers may supports other language linkages. GCC for example supports extern “Java” which allows interfacing with java code (though that’s quite cumbersome). extern “C” … Read more

constexpr initializing static member using static function

The Standard requires (section 9.4.2): A static data member of literal type can be declared in the class definition with the constexpr specifier; if so, its declaration shall specify a brace-or-equal-initializer in which every initializer-clause that is an assignment-expression is a constant expression. In your “second attempt” and the code in Ilya’s answer, the declaration … Read more

Constant expression initializer for static class member of type double

In C++03 we were only allowed to provide an in class initializer for static member variables of const integral of enumeration types, in C++11 we could initialize a static member of literal type in class using constexpr. This restriction was kept in C++11 for const variables mainly for compatibility with C++03. We can see this … Read more

Why do members of a static class need to be declared as static? Why isn’t it just implicit?

I get asked questions like this all the time. Basically the question boils down to “when a fact about a declared member can be deduced by the compiler should the explicit declaration of that fact be (1) required, (2) optional, or (3) forbidden?” There’s no one easy answer. Each one has to be taken on … Read more