In C, how to configure the initial settings for some program, using key-value pairs, with any or all of: a plain text configuration file, environment variables, and options on the command line. Also, how to decide which method's values overide those from either of the other two. Then if values have been changed, to optionally update the ...
Whenever we load a VB project it will call initialize method of a User Control ( if there is any in the project). My problem is that is that I have some code in UserControl.initialize that will try to create instances of other COM objects. And on my build machine those controls are not registered. One option is to move the code to some o...
Having the following class:
public class SomeClass
{
private readonly int[] _someThings;
public SomeClass()
{
_someThings = new int[4];
}
public int[] SomeThings
{
get { return _someThings; }
}
}
How would I use the object initializer syntax to initialize the SomeThings property like in th...
So I always heard that class fields (heap based) were initialized, but stack based variables were not. I also heard that record members (also being stack based) were also not initialized. The compiler warns that local variables are not initialized ([DCC Warning] W1036 Variable 'x' might not have been initialized), but does not warn for...
Hello,
I have just recently battled a bug in Python. It was one of those silly newbie bugs, but it got me thinking about the mechanisms of Python (I'm a long time C++ programmer, new to Python). I will lay out the buggy code and explain what I did to fix it, and then I have a couple of questions...
The scenario: I have a class called A...
I'm getting started in Hibernate and so far it's not too hard. But I am confused about the hbm2ddl.auto property. Is there a way to manually execute whatever this does to initialize the database tables? I only want to do this after I make my database changes, not every time I run my program.
edit: what about at runtime? is there a way i...
E.g. which way is better
class Foo {
private string _Bar ;
Foo ( string bar)
{
_Bar = bar ;
}
public string Bar
{
get { return _Bar ; //more logic here
}
set { _Bar = value ; //more logic could be added
}
}
}
OR
class Foo {
private string _Bar ;
Foo ( string bar)
{
this.Bar = bar ;
}
publ...
I'm curious about the underlying implementation of static variables within a function.
If I declare a static variable of a fundamental type (char, int, double, etc.), and give it an initial value, I imagine that the compiler simply sets the value of that variable at the very beginning of the program before main() is called:
void SomeFu...
Can assign a pointer to a value on declaration? Something like this:
int * p = &(1000)
...
Hey everyone!
Could someone please help me understand this error in C for structures?
This is my code:
struct Orientation
{
char facing;
char sensor;
char mazeDir;
};
struct Orientation O[16];
O[0] = {'N', 'F', 'N'};
O[1] = {'N', 'B', 'S'};
O[2] = {'N', 'R', 'E'};
O[3] = {'N', 'L', 'W'};
O[4] = {'S', 'F', 'S'};
O[5] = {'S'...
Let's suppose I have an interface named "Controller". Several classes implement this interface and I don't know these classes (e.g. the class names are located in an xml-file). Now for this Controller-implementing classes to work they have to get some references to other objects (maybe data objects). And this is my question, namely what ...
I have a [Nonserialized] field in my class that is initialized inline:
[NonSerialized]
private bool running = true;
However, after deserializing an object I have running == false. This is not what I want. Can I force inline initializatin to work for all [NonSerialized] fields? Otherwise I will have to implement ISerializable...
...
Consider the following. I have two exported constants as follows:
// somefile.h
extern const double cMyConstDouble;
extern const double cMyConstDouble2;
and
// somefile.cpp
const double cMyConstDouble = 3.14;
const double cMyConstDouble2 = 2.5*cMyConstDouble;
These constants are now referenced some place else to define two static (...
In Hidden Features of Java the top answer mentions Double Brace Initialization, with a very enticing syntax:
Set<String> flavors = new HashSet<String>() {{
add("vanilla");
add("strawberry");
add("chocolate");
add("butter pecan");
}};
This idiom creates an anonymous inner class with just an instance initializer in it, w...
Hello everybody.
I have good knowledge in Php, Mysql, and with Stack Overflow users help i started understanding a bit more of Javascript. Which by the way thanks for all those who have helped so far.
I always want learn a bit more, and I always had a little admiration for Ajax, and once in Ajax i can use Php and MySql...
So i wanted ...
I've been reading up on RAII and single vs. two-phase construction/initialization. For whatever reason, I was in the two-phase camp up until recently, because at some point I must have heard that it's bad to do error-prone operations in your constructor. However, I think I'm now convinced that single-phase is preferable, based on quest...
In order to ensure that some initialization code runs before main (using Arduino/avr-gcc) I have code such as the following:
class Init {
public:
Init() { initialize(); }
};
Init init;
Ideally I'd like to be able to simply write:
initialize();
but this doesn't compile...
Is there a less verbose way to achieve the same effect?...
Good Day,
Is there any difference on whether I initialize an integer variable like:
int i = 0;
int i;
Does the compiler or CLR treat this as the same thing? IIRC, I think they're both treated as the same thing, but I can't seem to find the article.
coson
...
I have a Java class that looks like this:
public class My_ABC
{
int a=0;
boolean B=true;
static // Initialize and load existing data only once at start-up
{
// need to know if it's called from its own main()
// or by another class to conditionally set veriables
}
public My_ABC(int AA,boolean BB)
{
}
publ...
I am currently taking a c++ course and trying to get a deep understanding of the whole thing.
I came up with some theories, it would be great if somebody could confirm them:
Every variable (local,global,staic,member and non-member) is guaranteed to have its ctor called before first use
The ctors of primitives like int are essentially n...