Tags "constructor" Result

using a Constructor statement (constructor?)

I'm new to Java, so I'm sure this is an easy question (my head is spinning from studying all day long). Here's the code I'm studying and can't remember/figure out what this line of code is doing: public Temperature(String type, double degrees) { if (type.equalsIgnoreCase("C")) Is this considered a constructor? What are the two parameters "Stri

it1352 2 2019-05-14

Why do constructors not return values?

Please tell me why the constructor does not return any value. I want a perfect technical reason to explain to my students why the constructor does not have any return type. Solution What actually happens with the constructor is that the runtime uses type data generated by the compiler to determine how much space is needed to store an object instan

it1352 0 2019-05-14


i have the following class sequence { public: sequence (const sequence& mysequence, const int newjob) { job_sequence(mysequence.job_sequence) job_sequence.push_back(newjob); ... } vector<int> job_sequence; } what i want is: if i have a sequence object, i want to be able to create a new object that copies the job_sequence within it and

it1352 2 2019-06-25

Delphi constructor and class constructor

I have a doubt that I cannot solve. I have read the documentation at embarcadero for class constructors but I cannot understand the meaning of that. In other words, what is the usage difference between a constructor and a class constructor? I did this: type TGeneric<T> = class private FValue: T; aboutString: string; procedure s

it1352 3 2019-05-15

Copy Constructor and default constructor

Do we have to explicitly define a default constructor when we define a copy constructor for a class?? Please give reasons. eg: class A { int i; public: A(A& a) { i = a.i; //Ok this is corrected.... } A() { } //Is this required if we write the above copy constructor?? };

it1352 1 2019-05-10

Java call constructor from constructor

I have a constructor private Double mA; private Double mB; Foo(Double a) { mA = a; mB = a 10; } Foo(Double a, Double b) { mA = a; mB = b; // some logic here } if I make a call to second constructor like this: Foo(Double a) { Double b = a 10; this(a, b); } than compiler tells me, that constructor should be the first statem

it1352 0 2019-05-22

Defaulted constructor vs implicit constructor

It's possible that someone has already asked about this but googling for "default", "defaulted", "explicit" and so on doesn't give good results. But anyway. I already know there are some differences between an explicitly defined default construtor (i.e. without arguments) and an explicitly defined defaulted constructor (i.e. with the keyword defau

it1352 0 2020-10-08

Call constructor from constructor in C

As a C# developer I'm used to run through constructors: class Test { public Test() { DoSomething(); } public Test(int count) : this() { DoSomethingWithCount(count); } public Test(int count, string name) : this(count) { DoSomethingWithName(name); } } Is there a way to do this in C ? I tried ca

it1352 0 2019-05-10