Hello again. I have a new puzzle for you :-).
I was thinking on how should an application handle his own start up. Like : checking for required libraries, correct versions, database connectivity, database compatibility, etc. To be specific, here is the test case. I use SWT and Log4J, for obvious reasons. Now, the questions :
Should ...
Let's say I have a class:
class Aggregate {
public:
int x;
int y;
};
I know how to initialize an object using curly braces:
Aggregate a1 = { 1500, 2900 };
But I can't find a proper syntax to create temporary object and pass it as an argument to some method, for example:
void frobnicate(const Aggregate& arg) {
// do...
I have some String variables which are getting the values from invoking the function getParameter() and some of this variables will probably be null.
Later, I will evaluate this variables using equals() method.
Should I set all the String variables to the empty String ("") if they are null to avoid any problems?
...
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 load, before main() or not at all). Even i...
Hi,
I have a navigation based application with two levels, in the second level the user select an option which should cause initialization and loading of the proper Nib file (there is a Nib file for every available selection).
Now I'm doing the initialization in a switch, based on the user selection.
The problem is that I'm adding Nibs...
I would like to create a list like this
list = []
for i in range(150):
list.append({'open': False, 'serve': False})
But is there a better way in Python to do it ?
...
I'm currently reading "the red book" for learning OpenGL properly, and in one of the first examples, the author writes a line that says "InitializeAWindowPlease();" as a place holder for the code that will make a window to draw the OpenGL content in.
Since I'm using Xcode for my programing, I know that I "get" a window to work with aut...
If I have this class:
class A
attr_accessor :b,:c,:d
end
and this code:
a = A.new
h = {"b"=>10,"c"=>20,"d"=>30}
is it possible to initialize the object directly from the hash, without me needing to go over each pair and call instance_variable_set? Something like:
a = A.new(h)
which should cause each instance variable to be ini...
(I looked everywhere for this, perhaps my googling skill is off today)
I have a program that requires a handful of initialization cmds from stdin (and not through arguments). It'd be nice to move those commands into a script so when the script completes I can start keying the real work. So something like:
cat initcmds.txt | myprogram.e...
When i have declaration like:
class Professor
{
string profid;
public string ProfessorID
{
get { return profid;}
set { profid=value;}
}
student st;
}
class student
{
string name;
string id;
public string Name
{
get { return name;}
set { name=value; }
}
public string StudentID
{
get { ...
I've heard about this happening in non thread-safe code due to improperly constructed objects but I really don't have the concept down, even after reading about in in Goetz's book. I'd like to solidify my understanding of this code smell as I maybe doing it and not even realize it. Please provide code in your explanation to make it stick...
So, the C++ standard requires that class members be initialized in the order in which they are declared in the class, rather than the order that they're mentioned in any constructor's initializer list. However, this doesn't imply anything about the order in which the arguments to those initializations are evaluated. I'm working with a sy...
How do I declare a generic variable in Scala without initializing it (or initializing to any value)?
def foo[T] {
var t: T = ???? // tried _, null
t
}
...
Quick question-- if in C I write:
int num;
Before I assign anything to num, is the value of num indeterminate?
...
I found some struct initialization code yesterday that threw me for a loop. Here's an example:
typedef struct { int first; int second; } TEST_STRUCT;
void testFunc() {
TEST_STRUCT test = {
second: 2,
first: 1
};
printf("test.first=%d test.second=%d\n", test.first, test.second);
}
Surprisingly (to me), here's the...
Without initialization how is it possible to assign values to arrays?
string[] s={"all","in","all"};
I mean why did not the compile show error?.Normally we need to
initialize ,before assign values.
...
The problem is really simple, I have a class "Stock", I want to load its property "StockName", "StockCode' from the db.
so which patten should I use?
pattern 1) Use service class to create it
public interface IStockService{
Stock GetStock(string stockCode);
void SaveStock(Stock stock);
}
p...
What do the following phrases mean in C++:
zero-initialization,
default-initialization, and
value-initialization?
What should a C++ developer know about them?
...
Hi all,
I'm quite certain that arrays of built in types are unitialized, whereas arrays of UDTs are default initialized.
int foo[5]; // will contain junk
Foo foo[5]; // will contain 5 Foo objects that are default initialized
This occurs regardless of whether the array is allocated on the stack or heap.
However, I'm finding it hard ...
let's say I have
std::map< std::string, std::string > m_someMap as a private member variable of class A
Two questions: (and the only reason I'm asking is because I came across code like that)
What's the purpose of this line:
A::A() : m_someMap()
Now I know that this is intialization, but do you have to do this like that?
I'm c...