6
голосов
4ответов
3247 просмотров

Passing Static arrays as parameters for Dynamic arrays in Delphi

I have this array: const / var _Data : array [0..4] of array [0..3] of Double = ((0,0,0,0), (0,0,1,1), (1,0,1,0), (1,1,0,0), (1,1,1,1)); I wanna pass it as param value for this procedure: procedure NN.NetTraining(Data: TDoubleMatrix); Where: TDoubleArray = ...

2
голосов
4ответов
8671 просмотров

SqlConnection as a static singleton object

public class db { public static string connectionString = WebConfigurationManager.ConnectionStrings["connectString"].ConnectionString; public static SqlConnection OpenConnection() { SqlConnection connection = new SqlConnection(connectionString); connection....

7
голосов
4ответов
2817 просмотров

Scala: how to inherit a "static slot"?

Well, I'm learning Scala so this question may be too basic for most people. In Java I can have a static slot (function or variable) in a class, and then I will have that slot in inherited classes too. In Scala I don't have static slots, but I have companion objects. But I'm finding out that tho...

21
голосов
3ответов
9789 просмотров

Does C# have an equivalent of Java static nested class?

I am converting Java into C# and have the following code (see discussion in Java Context about its use). One approach might be to create a separate file/class but is there a C# idom which preserves the intention in the Java code? public class Foo { // Foo fields and functions // ... ...

2
голосов
4ответов
1843 просмотров

Should I refactor static nested classes in Java into separate classes?

I have inherited code which contains static nested classes as: public class Foo { // Foo fields and functions // ... private static class SGroup { private static Map<Integer, SGroup> idMap = new HashMap<Integer, SGroup>(); public SGroup(int id, String type) { //...

8
голосов
5ответов
4155 просмотров

5 ways to use the static keyword in Java

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. Declar...

0
голосов
2ответов
361 просмотров

php5 extend main class and use statics

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()...

1
голосов
2ответов
619 просмотров

Static Global Fields in a Shared Library - Where do they go?

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 ...

0
голосов
3ответов
52 просмотров

Can I web-serve a document from one place and its content-type from another?

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 a...

0
голосов
4ответов
301 просмотров

C# inheritance design-pattern question

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...

4
голосов
5ответов
2768 просмотров

How to define (non-method) functions in header libraries

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 binar...

0
голосов
5ответов
244 просмотров

When create a static method

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 o...

4
голосов
3ответов
1367 просмотров

static/private child component in mxml?

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?

454
голосов
11ответов
385882 просмотров

Static constant string (class member)

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 ...

1
голосов
3ответов
171 просмотров

Is it possible to have 2 Base class's which already inherit from something inherit or know of a third common class?

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 Variab...

8
голосов
4ответов
2083 просмотров

How SHOULD you make (and use) static libraries on the iPhone

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 allo...

21
голосов
4ответов
36073 просмотров

ASP.NET C# Static Variables are global?

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 ...

4
голосов
5ответов
2959 просмотров

Overuse of static in my Java Game project?

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...

12
голосов
2ответов
3737 просмотров

How does HttpContext.Current work in a multi-threaded environment?

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...

0
голосов
2ответов
11490 просмотров

php how to: save session variable into a static class variable

Below code works fine: <?php session_start(); $_SESSION['color'] = 'blue'; class utilities { public static $color; function display() { echo utilities::$color = $_SESSION['color']; } } utilities::display(); ?>...

1
голосов
3ответов
3102 просмотров

Static vs Instance members in Stateless EJBs

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 mem...

3
голосов
2ответов
1232 просмотров

How do I avoid 'call is ambiguous...' error when writing static and non-static methods in C#?

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] ,,"] com...

5
голосов
3ответов
1604 просмотров

Auto versioning static content

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 ?...

60
голосов
3ответов
52043 просмотров

Template static variable

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 ...

5
голосов
5ответов
2868 просмотров

Why isn't SqlConnection disposed/closed?

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"]) ...

1
голосов
3ответов
1791 просмотров

Are C# extension methods only available for instance methods?

I have recently started to make useful use of C# extension methods. The SO examples and the documentation suggest that they are only used for instance methods (i.e. with the this keyword). It is possible to use them (or another approach) with static/class methods? (My particular requirement is ...

1
голосов
1ответов
110 просмотров

How do I require Gosu with IronRuby?

I tried to require Gosu's .so file, but it said something about "expecting assembly". I assumed that IronRuby will support library files which aren't written in dot net, is this true?

0
голосов
1ответов
51 просмотров

How to make a library depending statically to link dynamic on HP?

I built few open source binary/libraries and found that the binary/library is dependent on other libraries statically.I want it to link dynamically. This would allow my binaries be moved to any location and will be path independent. I mean if i export the Library path the binary should be able to...

3
голосов
2ответов
1705 просмотров

Compiling a 'static' binary from fortran on mac

I would like to compile fortran code on mac such that it does not depend on any shared library. Ultimately, I want to be able to send the binary to other people and for it to just work (provided the processor has the right architecture). I noticed that g95 and ifort have a -static flag, which doe...

9
голосов
5ответов
2606 просмотров

C++ static global non-POD: theory and practice

I was reading the Qt coding conventions docs and came upon the following paragraph: Anything that has a constructor or needs to run code to be initialized cannot be used as global object in library code, since it is undefined when that constructor/code will be run (on first usage, on library ...