initialization tag

16 questions


1 answers
250 views
0
Is there a reason why dynamic arrangement should not be declared like this?

The size of the array is determined at compile time, so to declare an array of dynamic sizes int size;scanf(%d, &size);int* arr = (int*)malloc(sizeof(int) * size); I was taught to do this, but eve...


1 answers
71 views
0
What's the way to initialize a line in ArrayList?

ArrayList<String> places = new ArrayList<String>(); places.add(Buenos Aires); places.add(Córdoba); places.add(La Plata);For example, there is a source like this, and I want to reduce the i...


1 answers
131 views
0
How do I initialize HashMap myself?

Map<String,String> test = new HashMap<String, String>{test:test,test:test};Is there a way to initialize HashMap like the code above? Is the code above grammatically correct?


1 answers
126 views
0
To initialize a C array

I want to initialize the same value from beginning to end when declaring an array.Now int myarr[30];for(i=0; i<30; i++) myarr[i] = 3;I'm doing a for statement like this, but not memset()myarr[all] ...


1 answers
159 views
0
To declare and initialize ANSI Structure separately?

How can I declare and initialize the structure in a different place?For example, in this code,typedef struct MY_TYPE { boolean flag; short int value; double stuff;} } MY_TYPE;void function(void) { MY_...

1 years ago

1 answers
75 views
0
Is there an easy way to initialize the entire C/C++ array to -1?

int array[100] = {0};I heard that the entire silver element is set to zero, so I thought I just need to set oneint array[100] = {-1};So the first element is minus 1, and the rest is zero.I don't want ...


2 answers
72 views
0
This is a c++ char generator initialization question

#include<iostream>using namespace std;class Test{ private: char* str; public: Test(char* name){ str=name; } void hello(void){ cout << str; }};int main(){ Test ptr(lee); ptr.hello(); ...


1 answers
71 views
0

1 answers
74 views
0
How to initialize private static members

How do I initialize private static member?There is an error in the way I did itld: 1 duplicate symbol for architecture x86_64clang: error: linker command failed with exit code 1 (use -v to see invocat...


1 answers
93 views
0
Static initialization block

Until now, I understood that static initialization block is used when it is impossible to set the value of the static field with one line.But I don't know why I need a special block for that work. For...

- 1 - »

© 2024 OneMinuteCode. All rights reserved.