Initializers are called to create a new instance of a particular type. In its simplest form, an initializer is like an instance method with no parameters
Questions tagged [initializer]
684 questions
0
votes
4 answers
Function in constructor initialiser list?
Heyy, I am trying to switch from initialising my variables within the constructor to using the constructor initialiser list.
So instead of writing
Class::Class(int width, int height) {
this->width = width;
this->height = height;
}
I am doing…

A. D.
- 728
- 1
- 9
- 27
0
votes
1 answer
Adding event handler before initializier is called
I have my two classes MainWindow and Foo and have a slight problem considering timing:
class MainWindow : Window
{
internal void SomeMethod(string name)
{
Foo foo = new foo(name)
foo.MyEventHandler += EventHandlerMethod;
…

philkark
- 2,417
- 7
- 38
- 59
0
votes
3 answers
Expected initializer before function name in header. C
I'm getting "expected initializer before 'read_file' as an error. The error is on the line "instruction code[] read_file(instruction code[])." Its on line Been searching the web for help, all im finding is c++ related post, so to clarify this is for…

slinhart
- 562
- 5
- 17
0
votes
0 answers
initializing an object array in more than one method java
I cant initialize the array made of object results in all methods.
If i dont initialize the array in every method it wont work but by doing this all data entered wont be saved in the array.
public class Processes {
Results [] list = new Results…
0
votes
1 answer
Initilize an array-like class with something resembling an initializer list?
I have a numerical Vector class, which is a wrapper on a float array, and I am sick of element-by-element initialization:
Vector vec(3);
vec(1) = 1;
vec(2) = 2;
vec(3) = 3;
Without using C++11 (Boost ok, but not preferable), what operators and…

Philip G. Lee
- 420
- 1
- 3
- 8
0
votes
0 answers
Rails refuses to forget code, leaving ssl and initialize method errors
I am noticing a pattern of rails acting as if a line of code is still written once it has been deleted, and I think it may have something to do with changing its defaults too much. I have two examples.
In the first, I set config.force_ssl => true in…
0
votes
1 answer
In AS3, how do I run code when a when the movie starts?
I'm making a level editor for my game, and would like to be able to access a list of all the classes included in my game. I have a static function in my Main class:
public static function register(c:Class, category:String):void {
if…

Alex Varga
- 1,752
- 2
- 14
- 17
0
votes
3 answers
Is it possible to programmatically check if an enum has an initializer set on it?
I want to get an enum as an int, but only if it has an initializer applied to it - so that I know that the value was explicitly defined and isn't just the default value. This is because I am using enums to represent a mapping with defined int…

lintmouse
- 5,079
- 8
- 38
- 54
0
votes
1 answer
XCode IOS method input from const unsigned char for an array
Currently I have a number of instance methods for generating some data that I would like to change for a single method that takes an input which I pass to it, the compiler is telling me that the array initializer must be an initializer list or…

Wez
- 57
- 1
- 8
0
votes
1 answer
Issues with creating a CCParallaxNode in cocos2d?
I'm using a CCParallaxNode for a scrolling background in my GameLayer and I'm getting a bunch of errors and I can't figure out why.
"Initializer element is not a compile-time constant" and also "Unk
@implementation Background
// Load the sprites…

Surz
- 984
- 3
- 11
- 36
0
votes
1 answer
iOS error, message sent to deallocated instance
I have written my own class (subclass of a NSObject) and have also written a custom initializer for it. The problem I am running into is, when I start my application, and call the refreshData instance method, everything works as it should. When I…

Jon Erickson
- 1,876
- 4
- 30
- 73
0
votes
2 answers
Objective-c class initializer executes multiple times
Unless I misunderstood it, this LINK from Apple's documentation clearly states that the class initializer, "+ (void)initialize)", only executes once per class.
Here is the excerpt:
Special Considerations
initialize it is invoked only once per…

apisip
- 333
- 1
- 4
- 10
0
votes
1 answer
.Net return initializer?
I’m trying to get my head around this. I know about object initializers in recent versions of .Net but the code below confuses me. First is the calling code, and below that I’ve put the needed class and interface definitions.
var mockCustomer =…

larryq
- 15,713
- 38
- 121
- 190
0
votes
1 answer
global values not updating when changed in config/initializers/constants.rb in Rails
I am working on a rails project and I am trying to update some of the global arrays used for selection fields in the application. I went into the constants.rb file where all the array definitions reside. I modified the values to be what I wanted.…

Alan DeLonga
- 454
- 1
- 10
- 27
0
votes
2 answers
What is an invalid initializer? Where is it in my code, and how do I correct it?
I am running my code on compilr.com and am using C as my language. I am trying to make a simple game where you have an inventory and start out with $100. You gain money by doing jobs secretly for other players. But, I'm getting an error message that…
user1707643