initialization Questions

8

Solved

Is it possible to create an object from a dictionary in python in such a way that each key is an attribute of that object? Something like this: d = { 'name': 'Oscar', 'lastName': 'Reyes', 'age':...
Fourthclass asked 17/3, 2010 at 21:54

18

Solved

What is the best way to initialize a private, static data member in C++? I tried this in my header file, but it gives me weird linker errors: class foo { private: static int i; }; int foo::i = ...
Trigg asked 9/10, 2008 at 3:34

1

Solved

I have been trying to understand how static variables are initialized. And noted a contradiction about the order of constant initialization and zero initialization at cppref and enseignement. At cp...

5

Solved

I am making some revisions from the lecture slides and it says a constructor is executed in the following way: If the constructor starts with this, recursively execute the indicated constructor, ...
Hypothesize asked 1/6, 2010 at 10:13

2

Solved

I have an app built with Jersey.I need to do some initialization on startup of the webapp/war in the Tomcat 7 container by running an application specific login/code. What is the best way to do th...
Barrada asked 15/9, 2011 at 0:8

8

Solved

So I'm declaring and initializing an int array: static final int UN = 0; int[] arr = new int[size]; for (int i = 0; i < size; i++) { arr[i] = UN; } Say I do this instead... int[] arr = new...
Scalage asked 6/8, 2010 at 18:58

4

Solved

I'm looking for a possibly non-verbose portable way to initialize a hash table in Common Lisp. E.g. something that works for constant hash tables, but also to pre-load variable hashes. In CLISP I a...
Obscene asked 22/5, 2012 at 16:19

14

I had a MyViewController.swift and a MyViewController.xib presenting the layout of MyViewController. I tried different methods to load this view controller including: //1 let myVC = UINib(nibName...
Asymptotic asked 5/5, 2016 at 9:5

6

Solved

With my code I get 3 messages all saying object initialization can be simplified and in my ever growing thirst for knowledge (and my OCD) I would like to "fix" my code so that these messages dont a...
Gauffer asked 25/4, 2017 at 9:1

2

For example, is the following function legal: struct two_int { const int a, b; } void copy_two(const two_int *src, two_int *dest) { memcpy(dest, src, sizeof(two_int)); } It seems like at leas...
Irruption asked 11/2, 2017 at 21:0

0

I am trying to run a function on initiation in SwiftUI, but it doesn't seem to be working. import SwiftUI @main struct ExampleApp: App { init() { print("app initiated") } var body: s...
Capelin asked 9/8, 2021 at 18:2

7

Solved

in C++ I want to initialize a double matrix (2-dimensional double array) like I would normally do without pointers like so: double data[4][4] = { 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }; Howev...
Oncoming asked 24/8, 2010 at 7:14

0

Just an instructive interview question: "What does this C++14 program print?" #include <iostream> struct A { int i; }; struct B { A a{1}; operator int() { return a.i; } }; int...
Beata asked 7/8, 2021 at 5:49

3

Solved

I have the following City class. Each city object contains a dictionary which keys are language tags (let's say: "EN", "DE", "FR"...) and which values are the city names in the corresponding langua...
Content asked 12/6, 2012 at 14:39

6

Solved

I simply want to create an empty 10*3*2 array with Python. I first thought of these one, but this is not working: parameters = [ [ [] * 2 ]*3 ] * 10 this gives me a vector of ten vectors, with ...
Niblick asked 12/11, 2012 at 16:32

1

Solved

I have a simple code: #include <atomic> int main() { std::atomic<int> a = 0; } This code compiles fine with GCC 11.1.0 with -std=c++17, but fails with -std=c++14 and -std=c++11. usi...
Tripoli asked 10/7, 2021 at 13:43

1

Solved

A friend of mine showed me a program in C++20: #include <iostream> struct A { A() {std::cout << "A()\n";} ~A() {std::cout << "~A()\n";} }; struct B { cons...

8

Solved

I have a class with minimum 4 variables and I have made a constructor for the class so that I can initialize it with MyClass testobj = new MyClass(1234,56789,"test text", "something ...
Ringmaster asked 26/6, 2013 at 14:1

2

Solved

I am reading through the cppreference page on default initialization and I noticed a section that states something along these lines: //UB int x; int y = x; //Defined and ok unsigned char c; uns...
Lindie asked 2/7, 2021 at 4:14

3

When I define an Array in Julia: z = Array(Float64, 1) it appears a random value is assigned. Sometimes it is 0.0, but mostly it is something like 3.78692e-316. Is this behaviour intended? And...
Heterolecithal asked 28/5, 2014 at 6:8

1

Solved

I know that in C++ the declaration of members in the class header defines the initialization order. Can you tell me why C++ choose this design? Are there any benefits to force the initialize order ...
Haihaida asked 30/6, 2021 at 5:21

9

Solved

As the title says, what exactly is the difference between public static String myString = "Hello World!"; and public static String myString; static { myString = "Hello World"; } is there an...
Timelag asked 18/3, 2013 at 19:51

2

TLDR; To run an initialization function for each process that is spawned by celery, you can use the worker_process_init signal. As you can read in the docs, handlers for that signal should not be ...

3

Solved

I have the following struct in my C++ code (I am using Visual Studio 2010): struct mydata { string scientist; double value; }; What I would like to do is to be able to initialize them in a qui...
Malposition asked 16/12, 2011 at 13:0

8

Solved

I am fairly new to VBA, so this may be a simple question but here goes. I would like to initialize an entire array myArray, say of integers, in VBA. I know that I can do this by a simple initializ...
Latrice asked 12/10, 2013 at 17:15

© 2022 - 2024 — McMap. All rights reserved.