initialization Questions

17

Solved

I want to initialize a struct element, split in declaration and initialization. This is what I have: typedef struct MY_TYPE { bool flag; short int value; double stuff; } MY_TYPE; void function...
Antidepressant asked 1/12, 2008 at 13:13

13

How should I use array of function pointers in C? How can I initialize them?
Chelton asked 31/10, 2008 at 6:45

3

Solved

I want to have init from rawValue for my enum in Swift to return default value if rawValue init will return nil. Right now I have something like this: public init(fromRawValue: String){ self = La...
Does asked 31/1, 2016 at 21:23

11

Solved

I heard a saying that c++ programmers should avoid memset, class ArrInit { //! int a[1024] = { 0 }; int a[1024]; public: ArrInit() { memset(a, 0, 1024 * sizeof(int)); } }; so considering the ...
Sidwohl asked 29/12, 2009 at 17:52

2

Solved

In C++ I have this struct from C. This code is very old and cannot be modified: struct Point { double coord[3]; }; On the other hand, I have this modern function which returns modern std::array i...
Tetramethyldiarsine asked 19/12, 2023 at 8:56

11

Is that possible to initialize object directly as we can do with String class in java: such as: String str="something..."; I want to do same for my custom class: class MyData{ public String ...
Nolie asked 17/8, 2012 at 12:13

2

Can bash associative arrays be initialized in a (...) list similarly to non associative arrays? Format? Updating to give an answer using the comments. Yes, the format depends on the version of bash...
Sightread asked 17/2, 2022 at 17:11

4

Solved

I am trying to deploy a Spring web application to Tomcat 7.0.24 but it hangs upon startup with the last lines showing as INFO: Deploying web application archive /usr/local/apps/tomcat-7.0.42/webap...
Carditis asked 4/4, 2014 at 19:45

20

Solved

After I have started Mongo using mongod.exe on a Windows 7 machine, I tried to start the mongo shell that failed with the error: Failed to connect to 127.0.0.1:27017, reason: errno:10061 No con...
Girondist asked 18/5, 2014 at 20:45

4

Solved

The __init__() function gets called when object is created. Is it ok to call an object __init__() function again, after its been created? instance = cls(p1=1, p2=2) # some code instance.__init__(p...
Pejorative asked 27/1, 2010 at 6:31

10

Solved

I am writing my testcode and I do not want wo write: List<string> nameslist = new List<string>(); nameslist.Add("one"); nameslist.Add("two"); nameslist.Add("three"); I would love to ...
Reluctance asked 14/12, 2010 at 10:31

35

Solved

I wanted to create a list of options for testing purposes. At first, I did this: ArrayList<String> places = new ArrayList<String>(); places.add("Buenos Aires"); places.add("Córdoba"); ...
Meaningful asked 17/6, 2009 at 4:10

4

Solved

Java 7 now has this "diamond syntax" where I can do things like ArrayList<int> = new ArrayList<>(); I'm wondering if C# has a similar syntax that I can take advantage of. For example, ...
Petcock asked 18/7, 2013 at 18:39

3

Solved

I try to using Livewire Binding Directly To Model Properties, and i get this error, Anyone help please ? Thank in advance. Typed property App\Http\Livewire\V2\Settings\Locations::$country must not...
Perichondrium asked 25/6, 2021 at 11:43

9

Solved

I'm currently working on some quite old C++ code and often find things like int i; i = 42; or Object* someObject = NULL; someObject = new Object(); or even Object someObject; someObject = ge...
Hershberger asked 23/3, 2011 at 10:51

27

Solved

I have a large array in C (not C++ if that makes a difference). I want to initialize all members of the same value. I could swear I once knew a simple way to do this. I could use memset() in my ca...
Reams asked 14/10, 2008 at 13:13

13

Solved

I found that in Java, there is a feature called static block, which includes code that is executed when a class is first loaded (I don't understand what 'loaded' means, does it mean initialized?). ...
Asyndeton asked 21/12, 2012 at 17:56

5

Solved

i've this implementation of singleton pattern in python, but i've noticed that the init is called, uselessly, everytime i call MyClass, despite the same instance is returned. How can i avoid it? ...
Entozoic asked 7/7, 2015 at 13:30

3

Solved

I am trying to create object of some class inside the Linq query but gives me an error as set title of the question. My query is: List<oneViewModel> workOrderInfoList = (from abc in db.ABC ...
Canzone asked 15/11, 2016 at 10:38

4

Solved

I would like to use a class that manages a thread (or several threads). Using composition, this would look like: class MyClass{ private: std::thread mythread; void _ThreadMain(); public: MyClas...
Rook asked 11/5, 2014 at 15:9

1

Solved

In the following program, struct A has both copy-constructor A(const A&) and a constructor from lvalue-reference A(A&). Then an object of A is thrown and then caught as const A: #include &l...
Fluorescence asked 23/2, 2022 at 12:29

2

Can atomic variables in C++11 be initialized globally? For example: std::atomic_int turnX = 5; int main() { /* ... */ } This fails with: error: deleted function ‘std::atomic<int>::atomic(co...
Latex asked 14/7, 2011 at 22:38

8

Solved

In kotlin we can check if the 'late' type variables are initialized like below lateinit var file: File if (this::file.isInitialized) { ... } Is it possible to do something similar to this in Dart...
Abram asked 21/4, 2021 at 14:29

8

Solved

I need to initialize all elements of a std::array with a constant value, like it can be done with std::vector. #include <vector> #include <array> int main() { std::vector<int> ...
Freshman asked 2/9, 2019 at 11:56

0

The current wording in [dcl.init.string] p1 states: An array of ordinary character type, [...] may be initialized by an ordinary string literal, [...], or by an appropriately-typed string-literal ...
Kubetz asked 21/8, 2023 at 10:59

© 2022 - 2024 — McMap. All rights reserved.