initialization Questions

11

Solved

Based on my reference, primitive types have default values and Objects are null. I tested a piece of code. public class Main { public static void main(String[] args) { int a; System.out.println(...

12

Solved

Can I initialize var with null or some empty value?
Planogamete asked 25/5, 2010 at 12:47

8

Solved

I get an error on line 6 (initialize my_foo to foo_init) of the following program and I'm not sure I understand why. typedef struct foo_t { int a, b, c; } foo_t; const foo_t foo_init = { 1, 2, 3...
Brazenfaced asked 11/6, 2010 at 17:55

4

Solved

I am searching for some help in next situation: I have some class and some method in it, syntax is like this: class SomeClass { public: void doSomething(int *a); }; So I want to call this ...
Hydrocellulose asked 5/10, 2011 at 7:17

11

Solved

Code like this often happens: l = [] while foo: # baz l.append(bar) # qux This is really slow if you're about to append thousands of elements to your list, as the list will have to be constantl...
Venavenable asked 22/11, 2008 at 20:56

5

There are different ways to initialize a variable in c++. int z(3) is same as int z=3. Is int z; z(3); same as int z; z=3; ?
How asked 20/3, 2014 at 20:3

9

Solved

I lazy load all my members. I have been doing this for a while and simply taken lazy load to be a good thing at face value. Let's say we have public class SomeClass { public int anInt; public S...
Frankie asked 13/10, 2011 at 13:39

7

Solved

Given this struct: struct PipeShm { int init; int flag; sem_t *mutex; char * ptr1; char * ptr2; int status1; int status2; int semaphoreFlag; }; That works fine: static struct PipeShm...
Good asked 29/7, 2012 at 14:17

4

Solved

UPDATE: Use structs and not classes. Struct is better in many ways has got an initializer of its own. This is my model class. Is it possible to create the init method automatically? Everytime I ha...
Snug asked 6/4, 2017 at 12:40

5

Solved

I have a Swift framework that defines a struct: public struct CollectionTO { var index: Order var title: String var description: String } However, I can't seem to use the implicit memberwise in...
Lupe asked 6/10, 2014 at 20:53

12

Solved

I am having troubles to understand the difference between both, or the purpose of the convenience init.
Habergeon asked 17/10, 2016 at 18:44

5

Solved

I've a question about initialization of inherited members in constructor of derived class. Example code: class A { public: int m_int; }; class B: public A { public: B():m_int(0){} }; This...
Piazza asked 21/10, 2010 at 4:11

2

Solved

I am trying to create an Azure function in which I am using some code with AutoMapper. I am quite new to C#, Azure and AutoMapper and I'm having some trouble finding the correct way of initializing...
Rida asked 29/11, 2017 at 10:56

2

Solved

I'm trying to follow this tutorial: https://www.drupal.org/node/2481341 The second step says: On global PHP level add curl.cainfo = [enter your path]\cacert.pem to your php.ini. How would I ad...
Tache asked 20/9, 2016 at 18:21

12

Solved

C++ Notes: Array Initialization has a nice list over initialization of arrays. I have a int array[100] = {-1}; expecting it to be full with -1's but its not, only first value is and the rest are...

3

In my program there is some frequently used data type with trivial fields struct Element { Element() noexcept : x( 0 ), y( 0 ), z( 0 ) {} float x, y, z; }; and also there are many pieces of code...
Taegu asked 21/10, 2022 at 19:31

5

Can anyone explain the output of following program? I thought constructors are initialized before instance variables. So I was expecting the output to be "XZYY". class X { Y b = new Y(); X() { ...
Gourami asked 11/2, 2013 at 3:41

2

Solved

I need to initialize each element of an array to a non-constant expression. Can I do that without having to first initialize each element of the array to some meaningless expression? Here's an exam...
Mathematician asked 3/10, 2014 at 19:36

2

Solved

There doesn't seem to be a standard constructor so I've taken to doing the following void myMethod(char delimiter = ',') { string delimiterString = 'x'; delimiterString[0] = delimiter; // use s...
Cryo asked 3/8, 2009 at 2:53

31

Solved

Which method of checking if a variable has been initialized is better/correct? (Assuming the variable could hold anything (string, int, object, function, etc.)) if (elem) { // or !elem or if (type...
Serology asked 25/2, 2011 at 3:44

4

Solved

I've searched stackoverflow for an answer but I cannot get something relevant. I'm trying to initialize a static structure instance with initial values by specifying their tags, but I get an error...
Braeunig asked 26/4, 2011 at 12:45

0

I came across a weird behaviour of SwiftUI's ForEach view. I've noticed that ForEach always initialize its child view twice as much as it should according to its repetition. Normally, when you rend...
Spruik asked 19/10, 2022 at 2:12

3

Solved

I have created a base class: class Thing(): def __init__(self, name): self.name = name I want to extend the class and add to the init method so the that SubThing has both a name and a time pro...
Arum asked 3/10, 2012 at 2:39

3

Solved

An obvious example of undefined behavior (UB), when reading a value, is: int a; printf("%d\n", a); What about the following examples? int i = i; // `i` is not initialized when we are rea...
Jester asked 23/5, 2021 at 18:17

2

Solved

Does have anyone way to autowire bean in Condition? There is an next example. We have 2 implementation of FileManager. One of implementation should be initialize in depends on property 'platform'...

© 2022 - 2024 — McMap. All rights reserved.