Initializers are called to create a new instance of a particular type. In its simplest form, an initializer is like an instance method with no parameters
Questions tagged [initializer]
684 questions
-3
votes
1 answer
What's "init" used for in swift?
Is there difference ? And the effect of deinit ?
struct mark {
var mark: Int
}
struct mark {
var mark: Int
init(mark: Int) {
self.mark = mark
}
}

di ding
- 11
- 1
-3
votes
2 answers
Initializer of constructor
First of all, for people who want to vote this down, note that the member variables were not shown in the class reference and the link to the header file was broken!
I have the following constructor:
Foam::IOobject::IOobject
143 (
144 const…

Streight
- 811
- 4
- 15
- 28
-4
votes
0 answers
Visual Studio gives an error that Arduino IDE don´t
I have followed a tutorial about publishing temperature data on a website run by an NodeMCU Arduino. When I compile it in Arduino IDE it works just fine but I wanted to change to Visual Studio mostly because of aesthetics and I get an error I just…

Magnus Karlsson
- 1
- 2
-4
votes
1 answer
C++ Constructor Initilizer
I am trying to use constructor initializer for name and time but the visual studio is giving me errors, I do not see any issues with it, it seems fine to me, I tried to see the problem, I tried other things as well, Please Help. Thanks you in…

coding
- 21
- 2
-4
votes
1 answer
initializer element not computable at load time
After upgrading from gcc 4.4.x to gcc 4.7.0, I started seeing:
error: initializer element not computable at load time
for the following snippet:
int prm_arr[] = {prm.field1, prm.field2, prm.field3};
This code worked fine with the gcc 4.4.x. I…

bkhote
- 1
- 2
-4
votes
1 answer
Why does this code output the first element in the initializer?
One of my friends sent me this code today:
#include
int main()
{
char *s = { "one", "two", "three", "four", "five" };
puts(s);
}
Its output is:
one
As I know, strings like "one" are translated as addresses in C, which are…

nalzok
- 14,965
- 21
- 72
- 139
-4
votes
2 answers
Unexpected errors, not sure why
I can not seem to get my code to run properly. I get the error message
"Error 1 error C2078: too many initializers, Line: 17 Column: 1"
and
"Error 2 IntelliSense: expected a ')' Line: 17 Comlumn: 21"
#include
#include…
-4
votes
1 answer
When to use initializers?
I recently came across the following bit of java syntax:
static {
...
}
apparently this is known as a "static initializer" (see Static Block in Java) and is "executed when the class is loaded".
When should a static initializer be used? What are…

tSchema
- 193
- 2
- 12
-7
votes
2 answers
C++, using initializers but for functions?
Look at the first class :
class A
{
public:
int x;
A(int v) { x=v; }
};
Also, take a look at class B ( i used inheritance )
class B : public A //Inheritance{
public:
B(int v) :A(v) {y=v; }
int y;
};
Now can you…

TheNewOne
- 1
- 2