Questions tagged [initializer]

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

684 questions
0
votes
2 answers

GCC compilation error, braces around scalar initializer [-Werror]

I'm new in C programming and I try to create a struct containing a char and a function pointer, and that is the problem. I want to change that code: switch (flag) { case 'd': case 'i': return (my_put_nbr(va_arg(ap, int))); case 'p': …
0
votes
1 answer

Initialise unit test class members upon declaration or in the TestInitialize method?

I understand that, when running unit tests, the class is instantiated for each test method. Therefore, I see no difference in initialising members upon declaration versus in the TestInitialize method. Is there anything particularly wrong about…
Neo
  • 4,145
  • 6
  • 53
  • 76
0
votes
1 answer

How to create a Initializer for layers.batch_normalization?

The default beta_initializer for layers.batch_normalization is: tf.zeros_initializer(). Is it possible to create a new initializer with an arbitrary value?
0
votes
1 answer

displaySize = invalid initializer

I have a method where I'm taking a screenshot, but there's 2 problems with it. For the 2 lines CGSize displaySize = [[CCDirector sharedDirector] displaySize]; CGSize winSize = [[CCDirector sharedDirector] winSize]; I get the warning Invalid…
Joethemonkey101
  • 149
  • 2
  • 18
0
votes
2 answers

When a constructor is called explicitly is the initializer and member variables constructed?

In the use of "placement new" it is suggested to call the constructor and destructor explicitly. In this case will the objects initialized in the initializer section of a class also get properly constructed? Same too with explicitly calling the…
JeffV
  • 52,985
  • 32
  • 103
  • 124
0
votes
1 answer

Argument labels for initialization parameters in Swift 3.1

Apple's book "The Swift Programming Language (Swift 3.1)" states the following: As with function and method parameters, initialization parameters can have both a parameter name for use within the initializer’s body and an argument label for use…
Robo Robok
  • 21,132
  • 17
  • 68
  • 126
0
votes
1 answer

How to use Object Method definitions without entering infinite loop

On MDN there is a sample example showing get and set used on an object initialization: var o = { property: function ([parameters]) {}, get property() {}, set property(value) {} }; Without any example showing how to use that structure I always…
Shadow
  • 4,168
  • 5
  • 41
  • 72
0
votes
1 answer

TensorFlow layers: using custom(ized) initialization function?

Why does obtaining a new initialization function with partial give me an error, while a lambda doesn't? All of these functions: f_init = partial(tf.random_normal, mean=0.0, stddev=0.01, partition_info=None) f_init =…
daniel451
  • 10,626
  • 19
  • 67
  • 125
0
votes
2 answers

Mixing char and string in C array init

I know that the following 2 initializers are equivalent: char T1[]="abc"; char T2[]={'a', 'b', 'c', 0}; I have an array initializer like this: char T[]={0x10, 0xF, 0xF0, 'H', 'e', 'l', 'l', 'o', 0xC1, 0xD0}; Leaving aside the signed/unsigned char…
dargaud
  • 2,431
  • 2
  • 26
  • 39
0
votes
3 answers

c++ constructor and initializer behavior. What's the difference between these 5 codes?

I'm new to c++ programming language. I wrote several patterns of code to understand c++ constructor and initializer. But I couldn't find out why one build fail and another doesn't. From my view, there seems no such difference that one fail and…
Kei Minagawa
  • 4,395
  • 3
  • 25
  • 43
0
votes
3 answers

How can I use an interface as type in java?

I have created an interface named Leen and created a class X that implements this interface, but when i go to main class to create a variable named x like this Leen x; x.printname(); The compiler gives me error: Connect.java:10: error: variable x…
0
votes
0 answers

Swift - Initializing a variable of structure arrays type

Sorry this is my first project in Swift3 and I hit lots of newbie questions (I come from C :) I am trying to create a variable to store the properties for a platform that runs on an Arduino. This code interacts with the Arduino via BLE. The platform…
Foxadn
  • 1
  • 1
0
votes
1 answer

C++ error "expected initializer before "

Good afternoon programmers, I am very new to C++. I use eclipse and I have an assignment that asks me to calculate a future population when given constant birthrates, deathrates, immigrantrates, and the current population. I get two errors. 1) On…
Jacob Fiola
  • 3
  • 1
  • 2
0
votes
1 answer

Initialize class depending on config value

I would like to find out how it is possible to initialize a Module, depending on a value. So I have a config.extend value which will decide if the core will instantiate of the Core or ExtendedCore module. However I am getting the error "value := is…
Mrchacha
  • 197
  • 1
  • 17
0
votes
2 answers

How do I handle this initializer?

Create a class called Parent with a title property and write an init and deinit method for your class. Write a subclass called Child. My problem is putting this into the code (call super.init(title:) and pass on the title parameter. class Parent { …
AllocSystems
  • 1,049
  • 2
  • 11
  • 16