Today, I found something in legacy code. It has "static new" for one function. It looks like this.
class Foo
{
public static void Do()
{
Console.WriteLine("Foo.Do");
}
}
class Bar: Foo
{
public static new void Do()
{
Console.WriteLine("Bar.Do");
}
}
I don't understand the static new modifier fo...
banging my head on this one. I have a static method with fields in a class similar to this:
public MyClass
{
private static string m_myString;
public static MyClass()
{
m_myString = "hello world";
}
public static void MyUsefulMethod(Foo bar)
{
DoStuffTo(bar);
}
}
In Debug mode, I have no issue but...
I'm using Boost.Serialization to archive the contents of a class. One of the member variables is a static std::vector.
Archiving and restoring goes fine, but I was kind of hoping the library would save static members only once, it appears that, judging by the filesize, the static members are fully saved for each archived instance.
This...
I am unsure about the scope of one static inner class of a non-static class.
In the lines below, would the variable DataContextCreator.Instance (part of a Singleton pattern) point to the same PDataContext instance for all Page objects/page requests or would each object have its own instance?
public class Page : System.Web.UI.Page
{
...
Just a quick and simple question, but couldn't find it in any documentation.
template <class T>
T* Some_Class<T>::Some_Static_Variable = NULL;
It compiles with g++, but I am not sure if this is valid usage. Is it?
...
I'm trying to serve static files for download in a django application, I figured that I'd put the static files in /media/files and have Apache set the content-type header to application/octet-stream (the files to download are going to be word files but I'll work out the details later).
To do this I activated mod_headers and then in the ...
I'll be writing a small desktop app for a client that has WinXP machines and they won't be installing the .NET framework (at least not for me).
So my choices are limited to either C++ or VB6, neither of which sound great.
I remember reading back in the day that Mono came up with a static compiler, but recently the only thing I could f...
Hi, I have the following code:
class SuperClass {
public static String getName() { return "super"; }
}
class SubClass extends SuperClass {
public static String getName() { return "sub"; }
}
public class Dummy<T extends SuperClass> {
public void print() {
System.out.println("SuperClass: " + SuperClass.getName());
...
If you have two threads invoking a static function at the same moment in time, is there a concurrency risk? And if that function uses a static member of the class, is there even a bigger problem?
Are the two calls seperated from each other? (the function is like copied for the two threads?)
Are they automatically queued?
For instance...
Once a class is loaded is there a way to invoke static initializers again?
public class Foo {
static {
System.out.println("bar");
}
}
Edit:
I need to invoke the static initializer because I didn't write the original class and the logic I need to invoke is implemented in the static initializer.
...
I have a hierarchy of classes. The base class uses some tuning parameters that are loadable from file (and reloadable during runtime). Each derived class may add some additional parameters. I am looking for a way to allocate a correctly sized parameters array in the base constructor, so that I don't have to deallocate and reallocate ...
I've defined a helper class to keep track of a small dictionary of items. it stores this information as a static property, which is initialized in the static constructor. the list is very small and will never change so I chose this method over xml or a db lookup table...
however what I would like to know is, will this static property re...
Given a group of objects that have a common set of properties and methods in support of given domain logic, is there a way of enforcing the presence of certain static methods on these objects?
I have concluded that implementing an interface does not achieve this (methods are instance only) and that static methods can not be marked overr...
I have a template class which has a static pointer-to-member, like this:
template<class T, T* T::*nextptr>
class Queue
{
T* head;
T* tail;
static T* T::*pnext;
};
My question is how to write the initializer of the static pointer-to-member. I tried the obvious case:
template<class T, T* T::*nextptr> T* Queue<T, nextptr>::*...
Is there any difference in these two? If so, what exactly is the difference? Assume they are in a C function that may be called multiple times.
declare and assign in same statement
static uint32_t value = x; // x varies and may be passed into function.
declare in one statement and assign in next statment.
static uint32_t value;
v...
Please see code below. The destructors are never called. Anyone know why and how this can be rectified?
public partial class Form1 : Form
{
private Goo goo;
public Form1()
{
InitializeComponent();
goo = Goo.GetInstance();
}
}
public class Goo
{
private foo f = new foo();
private sta...
I'm looking for the best Design for the following situation.
We have many objects form one class, for instance a picture frame. Now each of the picture frames can display 3 types of picture. 1) a face 2) a screenshot 3) empty
Thats easy:
public enum PictureMode
{
Face,
Screen,
None
}
public class PictureFrame {
priva...
Isn't a class with all static members/methods a kind of singleton design pattern? Is there any disadvantage in particular of having such classes? A detailed explanation would help.
...
Dear all,,
I want to know what could be the equivalent keyword in java which could perform same function as "Static keyword in C".. I want to do recursion in java, performing same function that a static keyword in C does...
Please help..
...
Hello,
I turned my C++ Dynamic link library into Static library just to acquire more knowledge.
My question is how can I use the .obj file to compile both projects with C# express/MS visual studio?
...