Given the method:
internal static DataSet SelectDataSet(String commandText, DataBaseEnum dataBase)
{
var dataset = new DataSet();
SqlConnection sqlc = dataBase == DataBaseEnum.ZipCodeDb
? new SqlConnection(ConfigurationManager.AppSettings["ZipcodeDB"])
: new SqlConnectio...
Hi folks!
I can't understand, why if we define static variable of usual (non-template) class in header, we have linker error, but in case of templates all works fine and moreover we will have single instance of static variable among all translation units:
It's template header (template.h):
// template.h
template<typename T>
class Templ...
Hi all,
I'm developing a PHP site that serves static content from a cookie free domain (Thanks SO Blog!), this domain serves content with a high cache which among other things means that I'm unable to change content (JS, CSS and images) without invalidating that cache. Currently I do this by appending ?revision (e.g. style.css?19) to t...
I have a number of classes that represents business transaction calls: executing appropriate stored procedures.
Now the looks like this:
public static class Request
{
public static void Approve(..) {
using(connection) {
command.Text = "EXEC [Approve] ,,"]
command.ExecuteNonQuery();
}
}
}
...
I have a stateless session bean which needs access to a factory class. Is it best to declare this factory class as a static or instance member in the SLSB? Am I correct in saying that, as SLSBs are reused, only one instance of the factory will be created per bean (when going with the instance member option), as opposed to one instance pe...
Below code works fine:
<?php session_start();
$_SESSION['color'] = 'blue';
class utilities
{
public static $color;
function display()
{
echo utilities::$color = $_SESSION['color'];
}
}
utilities::display(); ?>
This is what I want but doesn't work:
<?php ses...
So I'm left wondering how exactly asp.net is able to scope a static property, when (to my knowledge) asp.net is multi-threaded.
One theory goes that the ASP.NET guys maintain a different appdomain for every request ... but that doesn't seem feasible.
Another theory goes that the .Current method looks at the current Thread, and then use...
I am currently developing a little platform in Java and I wrote my own game engine for it called Bonsai. Now I'm asking myself the question "Did I overuse statics?".
On the one hand it's very convenient since I don't have to keep a reference to the game instance in each class like the map or the player. On the other hand... I have alrea...
Hi guys...
Today I released a small asp.net beta web application which allows internal staff to modify some product information. We started running into issues where users were overwriting each others product information... even though each staff member was editing a totally different row (Product).
After some searching on google, I th...
AFAICS, any serious iPhone developer must make and use static libs on a regular basis, or else condemn themselves to buggy, hard-to-maintain, unwieldy projects. But Apple refuses to provide any official docs on the process (just circular references: "dont do static, use dynamic! ... we don't allow dynamic on iPhone, use static!")
I have...
I have 2 class's
Class 1.
public class BaseContentPage : System.Web.UI.Page
{
}
Class 2.
public class BaseUserControl : System.Web.UI.UserControl
{
}
And now i want them to be aware of this class.
public class BaseCommon
{
public string Variable1 { get; set; }
public string Variable2 { get; set; }
public string Variable...
Hi guys.
I'd like to have a private static constant for a class (in this case a shape-factory).
I'd like to have something of the sort.
class A {
private:
static const string RECTANGLE = "rectangle";
}
Unfortunately I get all sorts of error from the C++ (g++) compiler, such as:
ISO C++ forbids initialization of
member ...
Are there any way to declare a child component in mxml which is private/protected or even static?
Sure we can do this inside a script tag, but are there any other way?
...
I use resharper and resharper adviced me to declare one method as static and the another not. But i can't understand why the other method can't be static ?
method recommended to be static
private static string Prehod(string retazec)
{
var pole = retazec.ToCharArray();
var output = "";
char? temp = null;
...
When writing a header library (like Boost), can one define free-floating (non-method) functions without (1) bloating the generated binary and (2) incurring "unused" warnings?
When I define a function in a header that's included by multiple source files which in turn is linked into the same binary, the linker complains about redefinition...
Hi,
I am storing data with different formats and lengths. I have a class hierarchy to represent this:
abstract class BaseDataFormat{
abstract void InitalizeFromBytes(byte [] );
}
class DataFormat1 : BaseDataFormat{...} // data stored in 3 bytes
class DataFormat2 : BaseDataFormat{...} /// data stored in 4 bytes
When I am readin...
Hi,
I am trying to write a web application that will serve uploaded files, and let the uploader specify the content type. For this to work, I need to be able to control the content-type when I serve the file. With most web-servers I'm aware of (e.g. Apache), the best I can do in that respect is set an appropriate suffix and hope that no...
I have a cpp file from which I am generating a shared library (using autofoo and the like). Within the cpp file, I have declared a couple of static fields that I use throughout the library functions.
My question is 2-part:
1) Where are these fields stored in memory? It's not as if the system instantiates the entire library and keeps ...
why I can't do like this?
<?php
class core {
public static $db;
function __construct() {
$this->db = new mysql('host', 'user', 'pw', 'db');
}
}
class stat extends core {
public static function log() {
core::$db->query("insert into mytable values(now())");
}
}
// do something
stat::log();
?>
...
I just had an interview where one of the questions was something like "Describe 5 ways to use the static keyword in Java." I could only think of 2 on the spot, and afterwards I found 2 more. What is the 5th?
Declaring a field belonging to a class as opposed to an instance of the class.
Declaring a method that can be called on a class...