initialization

Overloading Default Construction with Initializer List

I need to know how to get something to work. I've got a class with a constructor and some constants initialized in the initializer list. What I want is to be able to create a different constructor that takes some extra params but still use the initializer list. Like so: class TestClass { const int cVal; int newX; TestClass(i...

Dynamic initialization of controls in iphone

Hi all, I am tying to add the values from an array to a number of text boxes in my view. it is possible for me to make it work by implementing a1.text=[arrayName objectAtIndex:1]; Similarly i am having a1, a2, a3,... a45,... a60,... upto a99 Here "a1" is the outlet of a particular textfield. what i need is that, i have a plenty of c...

C - Dynamically initializing arrays.

I'm trying to find the equivalent of int myArray[n], except I don't know what n is without input. Is the following code supposed to work? (I need to use kmalloc instead of malloc). int * pages; //... later, after we find out n... pages = (int *)kmalloc(npages * sizeof(int)); Debugging using gdb, the value pages[0] doesn't seem to be ...

php Array Initialization

Hi, I need to initialize an array of objects in PHP. Presently I have the following code: $comment = array(); And when i am adding an element to the array public function addComment($c){ array_push($this->comment,$c); } Here, $c is an object of class Comment. But when I try to access an functions of that class using $comment,...

Initialize a list of objects in Python

Hi all, I'm a looking to initialize an array/list of objects that are not empty -- the class constructor generates data. In C++ and Java I would do something like this: Object lst = new Object[100]; I've dug around, but is there a Pythonic way to get this done? This doesn't work like I thought it would(I have 100 references to the s...

Initialization: T x(value) vs. T x = value when value is of type T

T x(value) is usually the better choice because it will directly initialize x with value, whereas T x = value might create a temporary depending on the type of value. In the special case where value is of type T though, my guess is that the expression T x = value will always result in exactly one copy constructor call. Am I correct? I'v...

C++ Static member initalization (template fun inside)

Hello all, For static member initialization I use a nested helper struct, which works fine for non templated classes. However, if the enclosing class is parameterized by a template, the nested initialization class is not instantiated, if the helper object is not accessed in the main code. For illustration, a simplified example (In my ca...

alloc/init and the setting of instance variables

It is my understanding that, in addition to allocating memory, alloc sets all instance variables (with the exception of the isa variable) to zero or to the equivalent type for zero, such as nil, NULL, and 0.0. But I recently read the following about init: Initialization sets the instance variables of an object to reasonable and ...

Reproducing static initialization order fiasco in C++

I read about the static initialization order fiasco in C++ relating to crash of the application. I think I understood it but still have few questions: 1) If I want to reproduce this problem, how can I do it (so that my program should crash)? I would like to write a test program to reproduce a crash. Can you please provide the source code...

Initialize UIPickerView

I want to create a UIPickerView with the easiest way possible, because all of what I know Is not enough to help me Ok what I ment is that I am trying to get a UISegmented that will end up creating a UIPickerView but I want to create a UIPickerView that shows up when I select one of the segments in the segmented control animated, and als...

Ruby on Rails: Passing argument to singleton

I have a Rails app that repeatedly talks to another Web server through a wrapper, and I'd like to stick the wrapper in a Singleton class so it's not recreated for every request. Easy enough, I thought: class AppWrapper < Wrapper include Singleton end ... wrapper = AppWrapper.instance "url" Only it doesn't work: wrong number of arg...

How to initialize static const pointer in a class ?

class School { static const int *classcapacity; }; This expression is from my exam and it need to get initialized how can i do that ? ...

How to call a model method immediately after my application loads in Ruby on Rails

How do I call a models method just after my application loads. This sets up some of the business rules in my application and I want to run this method every time my server is restarted or changes have been made to my production. What would be the best way to do this ...

Determine if script/server is being started

In Rails, in an initializer/environment.rb Whats the pefered way to detemrine if the webapp itself is being loaded (script/server). All the initializers are loaded for migrations script/console and other rails task as well, but in my case some stuff only has to be loaded when the server itself is being initialized. My ideas: checking ...

Can one initialise a java String with a single repeated character to a specific length.

I'd like to create a function that has the following signature: public String createString(int length, char ch) It should return a string of repeating characters of the specified length. For example if length is 5 and ch is 'p' the return value should be ppppp Is there a way to do this without looping until it is the required ...

When does applicationDidFinishLaunching run on IPhone simulator?

In an IPhone app, I put a breakpoint in appDidFinishLaunching, and when I invoked the program from the compiler using command-Return, the code stopped at my breakpoint. Then I shut down the program, but not the simulator. When I then invoked the program from the program icon, the code did not stop at my breakpoint. The breakpoint wa...

Why are "inlined" static consts not allowed, except ints?

Possible Duplicate http://stackoverflow.com/questions/370283/why-cant-i-have-a-non-integral-static-const-member-in-a-class struct Example { static const int One = 1000; // Legal static const short Two = 2000; // Illegal static const float Three = 2000.0f; // Illegal static const double Four = 3000.0; // Illegal ...

[C++] Why aren't pointers initialized with NULL by default?

I guess this have been answered before, but I just couldn't find the answer here or on Google, but I think that it is because I couldn't type the right question... Can someone please explain why aren't pointers initialized to NULL? Example: void test(){ char *buf; if (!buf) // whatever } The program wouldn't ste...

PowerPC initialization

Hi! Does someone know how to initialize a PowerPC 32-bit processor (e.g. PPC-440), similar to Intel's x86 protected mode switch and consequent initialization of address tables and the like? Is there documentation about the first steps an OS should take care of on these processors? Regards, ...

How can I access an object property set within an initializer?

I don't know if this is even possible, but how can I access an object property that has be set within an initializer so that I can use it to set another property within the same initializer? Here's what I'm trying to do: var usersWithCount = users .AsEnumerable() .Select( u => new User() { UserId = u.UserId, Us...