initialization Questions

2

Solved

In the following example that uses JDBC (this question though is not specific to JDBC): Connection conn = null; try { ..... Do the normal JDBC thing here .... } catch(SQLException se) { if(conn...
Grizel asked 10/11, 2014 at 21:58

2

Solved

The FastAPI application I started working on, uses several services, which I want to initialize only once, when the application starts and then use the methods of this object in different places. I...
Homologate asked 23/5, 2021 at 20:16

2

In Java we can initialize an array using following code: data[10] = {10,20,30,40,50,60,71,80,90,91}; How can we do this in Pascal?
Sherrard asked 10/11, 2015 at 5:28

5

Solved

I know that in C# you can nowadays do: var a = new MyObject { Property1 = 1, Property2 = 2 }; Is there something like that in PHP too? Or should I just do it through a constructor or through m...
Largish asked 1/10, 2010 at 9:26

3

Solved

I have a class member that looks like this class Controller { protected: // other stuff std::vector<Task<event_t, stackDepth>> taskHandlers; //some more stuf } The Task class is ...
Fluviatile asked 6/7, 2020 at 7:49

6

Solved

I want to initialize a two-dimensional array of variable size to zero. I know it can be done for a fixed-sized array: int myarray[10][10] = {0}; but it is not working if I do this: int i = 10; ...
Propraetor asked 15/9, 2010 at 14:41

4

Solved

In trying to serialize an array of float3 objects with the basic JSONEncoder, it's revealed that float3 does not conform to the Codable protocol, so this cannot be done. I tried to write a basic e...
Folberth asked 29/1, 2018 at 1:45

8

Solved

I'm kinda waiting for a 'no' answer on this question. I was interested if you can save a variable at the same time when you checking it in an if-clause. Let's say I have this code. if(foo!=null...
Futurism asked 19/2, 2009 at 7:47

8

Solved

Consider this example. Let's say I have this object which is ubiquitous throughout my codebase: type Person struct { Name string Age int [some other fields] } Somewhere deep in the codebase, ...
Pertain asked 5/2, 2019 at 18:15

5

Solved

I've checked myself, I wrote a program like this int main() { int i; cout << i; return 0; } I ran the program a few times and the result was same all the time, zero. I've tried it in C an...
Frequentation asked 11/5, 2015 at 16:3

6

I have the java configuration for the Spring Data Elaticsearch(using Transport Client) and ESTemplate. Here some except: @Configuration @EnableElasticsearchRepositories(basePackages = "subpack...

4

Solved

If we execute such two lines in any function, we will get an error, and this is logical because the variable b is defined after the initialization a=b: int a=b; int b=0; But when we insert these t...
Thereinto asked 8/6, 2023 at 7:41

9

Solved

Is there any way to do this in a condensed form? GLfloat coordinates[8]; ... coordinates[0] = 1.0f; coordinates[1] = 0.0f; coordinates[2] = 1.0f; coordinates[3] = 1.0f; coordinates[4] = 0.0f; coor...
Lima asked 20/8, 2010 at 22:55

1

Solved

protocol EmptyInitializable { init() } @propertyWrapper struct PropertyWrapper: EmptyInitializable { let wrappedValue: Int init(_ wrappedValue: Int = 0) { self.wrappedValue = wrappedValue }...

18

Solved

.NET offers a generic list container whose performance is almost identical (see Performance of Arrays vs. Lists question). However they are quite different in initialization. Arrays are very easy...
Tessie asked 21/1, 2009 at 20:54

25

Solved

I need to create a Set with initial values. Set<String> h = new HashSet<String>(); h.add("a"); h.add("b"); Is there a way to do this in one line of code? For instance, it's useful fo...
Laevorotatory asked 11/1, 2010 at 12:31

8

Solved

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 soli...
Nonmoral asked 19/10, 2009 at 12:30

1

Solved

Can I declare a C pointer with an intialization to its own address? void* p = &p; I am specifically concerned with if this is strictly standard compliant in C23 (as the draft currently stands)....
Coelostat asked 6/4 at 4:34

4

Solved

In C# it's possible to write: MyClass obj = new MyClass() { field1 = "hello", field2 = "world", field3 = new MyOtherClass() { etc.... } } I can see that array initialization can be done in...
Infix asked 12/7, 2011 at 17:8

2

Solved

I am new to using armadillo, and could not get the following in spite of trying / searching quite a bit. There are two huge (dynamic) arrays (not vectors) that I need to perform correlation on. I ...
Pinhead asked 14/10, 2013 at 22:10

5

Solved

If I have a method like this: public void DoSomething(int Count, string[] Lines) { //Do stuff here... } Why can't I call it like this? DoSomething(10, {"One", "Two", "Three"}); What would be...
Uniformed asked 13/9, 2009 at 0:2

13

Solved

#include <iostream> using namespace std; class T1 { const int t = 100; public: T1() { cout << "T1 constructor: " << t << endl; } }; When I am trying to i...
Pigweed asked 24/1, 2013 at 6:53

14

(Note: This question is about not having to specify the number of elements and still allow nested types to be directly initialized.) This question discusses the uses left for a C array like int arr...
Shaving asked 24/5, 2011 at 17:0

4

Solved

How do you initialize a boolean array in the Eigen library (C++) to a specific truth value? There are initializers for numeric matrices but I can't find an example for a boolean array (Eigen::Array...
Arcadia asked 13/11, 2014 at 4:57

4

Solved

I have built a working C library, that uses constants, in header files defined as typedef struct Y { union { struct bit_field bits; uint8_t raw[4]; } X; } CardInfo; static const CardInfo Y_CO...
Tab asked 19/7, 2012 at 7:16

© 2022 - 2024 — McMap. All rights reserved.