Most voted "builder" questions
Constructing object-oriented programming languages is a method called as soon as a new instance of the object is created. Such a method is usually responsible for allocating resources needed to function the object beyond the initial definition of the state variables (attributes). If the question is not about the "Constructor", do not use this tag, even if you are using the "Constructor" in your project.
Learn more…141 questions
Sort by count of
-
1
votes0
answers20
viewsWhat are the members' initialization lists and under what circumstances should they be used?
What is the purpose of a member initialization list that is used in class/struct constructors in the C++ language and under what circumstances it should be used.
-
1
votes1
answer654
viewsStandard constructor to calculate an employee’s annual salary in C#
I need to make a code that calculates the annual salary (float) from the months worked (int) and monthly salary (float), but it has to be using the constructor method. Here’s a code I made but it’s…
-
1
votes1
answer49
viewsClone a native javascript constructor without changing the original
I’m trying to create a personal library, where the original idea was to extend native javascript objects with various useful functions. After reading a little, I ended up convincing myself that…
-
1
votes1
answer29
viewsDoubt regarding the extension of the Date object
I’m having a problem whose cause I can’t identify. I have the following builder: class ExtDate extends Date { constructor () { super(); } foo() { console.log('bar'); } } Theoretically it should do…
-
1
votes2
answers102
viewsList something from a constructor
I have a code in Java that creates a client in the class Cliente: public class Cliente { String nomeCompleto; String dataNas; String email; String senha; } then I have the builder of this Cliente…
-
1
votes1
answer72
viewsHow to leave default value in Static Arraylist in Java?
I am making a program with login screen and have a question: I want settar an "administrator" account in a ArrayList static and do not know how to proceed (or if this would be something plausible).…
-
1
votes1
answer143
viewsWhat is the need to declare the constructor/super of an extended class?
I have a class, example: class Animal { constructor(raca) { this._raca = raca; } get raca() { return this._raca; } printRaca = function() { console.log(this._raca); } } And then I extend it this…
-
1
votes2
answers482
viewsWhen is it recommended to Initialize a final property in the Class constructor?
The example below is a summary of the original (Bringing it all Together) found on the official Flutter page. On the first call, the class Cart is initialized by the constructor and in the second…
-
1
votes2
answers165
viewsHow does a const constructor differ from a standard constructor?
In the documentation it says that the builder const Creates an object that will never change. All vars has to be final. So it means that I will have the same result in creating the following…
-
1
votes1
answer54
viewsDoubt about class Abstract and method __Construct?
I have the following class: abstract class Weeks { protected $year; protected $this_week; protected $last_week; /** * @param $date deverá ser no formato new DateTime(). **/ public function…
-
1
votes2
answers514
viewsPass class object as constructor parameter in C++
Good afternoon, you guys! I’m studying for a C++ test I’m doing this week, and I’m having a hard time passing an object as a constructor parameter. Could you explain to me the right way to do it? I…
-
1
votes0
answers37
viewsJavascript: method as object builder?
I would like to create a method within an object, but it assigns the properties to the object itself: Game = { personagens: [] }; Game.Personagem = function(obj = {}){ this.nome = obj.nome ||…
-
1
votes0
answers15
viewsHow to run a constructor in Pytest?
In my working directory, I have a folder that contains my package and another folder with test files. The directory tree is as follows: Current_dir/ MyPackage/ __init__.py file1.py file2.py tests/…
builderasked 4 years, 1 month ago JeanExtreme002 5,663 -
1
votes1
answer28
viewsWhy do I still have access to the current state of the object in this case? [EXAMPLE C#]
A very basic doubt, but it’s bugging my head. I have the following code snippet: A class that receives a list as a parameter in the constructor: public class MinhaClasse { IList<int> Items;…
-
0
votes1
answer569
viewsAndroid: Error Running Application
I noticed that using the shortcut Alt+Insert and selecting for him to give me the constructors, he tries to create a constructor with each property private (cManager and mTextView). I remember that…
-
0
votes2
answers306
viewsWhy do builders have to have the same class name?
Is it really necessary for the constructor to have the same name as the class?
-
0
votes2
answers236
viewsWhat would be the most efficient way to replicate this code? (Javascript)
Doubt With this code, I can only create and manipulate a "employee", I wanted to be able to add more employees by clicking a button and manipulate their data. HTML <!DOCTYPE html> <html>…
-
0
votes1
answer198
viewsWhen using the constructor when using load
Good night, how are you? I have a question, when to use the constructor and when to use the load of a form to call some method or etc. Example: public partial class Manutenção_cliente :…
-
0
votes1
answer40
viewsC++: Elements just below the constructor call of a class
In my teacher’s code, he passed the following class template, with the constructor defined below: template<typename T> class CircularBuffer { std::vector<T> _elements; size_t _first, _n;…
-
0
votes1
answer34
viewsHow do I value a value passed by Set?
I wanted to know how do I add a new value to length and width through setLength and Setwidth, and this value goes through validation ((x > 0 && x < 20)? x : 0): public class Rectangle…
-
0
votes1
answer573
viewsProblem calling base constructor in inherited constructor in C++
I’m taking data structures in college at C++ and this language is really crazy. I am trying to call the parent constructor in the constructor of the heirs classes, but the following error appears:…
-
0
votes1
answer42
viewsPHP constructor does not identify variable value
Could someone tell me why in "Parent::__Construct('$bill');", if I put a variable there it does not identify it? I tried anyway, it only works if I type the name of the table, this $account comes…
-
0
votes1
answer196
viewsHow to Overload a constructor and also call the base class constructor in C#?
I am creating a C# error that should extend the class Exception but, should also add an extra property, thus: public class CampoVazioErro: Exception { public string campo { get; } public…
-
0
votes1
answer456
viewsJavascript Constructor x is not a constructor error
I have a constructor and I wanted to create an object from it. But, ta giving Uncaught Typeerror: Map is not a constructor. I just wanted to know why? var mapa = null; var Map = (function (ol, $) {…
-
0
votes1
answer98
viewschar and constructors in c++
I need a constructor for a class that has char vectors as attributes, like this one: class Anthem { private: int Id; char Name[50]; char Country[50]; int Year; char Composer[30]; char Historic[200];…
-
0
votes1
answer65
viewsInitialize members of a structure, accessed via pointer, in the constructor of a C++ class
Imagine the class DateTime as follows: datetime.hpp: #ifndef DATETIME_HPP #define DATETIME_HPP #include <ctime> class DateTime { public: DateTime(); DateTime(int, int, int, int, int); private:…
-
0
votes1
answer183
viewsSpring MVC - Multiple Builders
I’m having a problem where a Framework I’m using needs a default constructor, this one calling my Service class: @Service public class FuncionarioService { private FuncionarioDAO dao; public…
-
0
votes1
answer1245
viewsHow to initialize an Arraylist in the constructor?
I have to develop a program in Java that will rent a library. In one part of the program I have to make a ArrayList of publications, follows the question: We must create a system for controlling…
-
0
votes1
answer58
viewsProblem making a method call in class constructor (javascript)
I am learning javascript and am getting the following error: setTitulo is not defined Why does this error happen? The setTitulo method should not be set since it belongs to the class? class Nota{…
-
0
votes1
answer59
viewsI cannot use an attribute started with the constructor in typescript
I am using typescript, typeorm, postgres and express; I am trying to start the Teamrepository class created by me through a constructor within the Teamcontroller class, but within the methods that…
-
0
votes1
answer836
viewsDart/Flutter: how to use return of one method in another method? both invoked in the Class Constructor
I am using Dart/Flutter to develop an application and in it I have two Firebase Listeners methods, as shown below, and I would like to know how, in the constructor method, I trigger one of the…
-
0
votes1
answer10
viewsInitialization list of members with attributes from another class (inheritance)
I know a member startup list declares and at the same instant initializes such an attribute(s), that’s what I know so far. In the following code: #include <iostream> // std::cout class Foo {…
-
-1
votes1
answer373
viewsInstantiating a class in another constructor in PHP?
I have a class called teacher who is heir to another so-called person, I am trying to instantiate a third class of connection with bank in the method constructing the Teacher class, but it is…
-
-1
votes1
answer118
viewsCreate new object without overwriting the old one in javascript
I have a form with several inputs, available at https://jsfiddle.net/elenderg/6hofsyzw/ The goal is that the user can store several aircraft, which have a number of values. How can I store this data…
-
-1
votes1
answer93
viewsError with namespace
I have the following folder structure: Inside the Form folder there is a file called Form.php (among others). Form.php belongs to the 'Book Widgets Form' namespace. There is another folder with the…
-
-1
votes3
answers57
viewsConvert stopwatch to hh mm ss format
My stopwatch is running without format 00:00:00 I created a div in index.html <!-- TIMER --> <div class="container"> <span id="display">00:00:00</span> </div> No js…
-
-2
votes1
answer69
viewsInstantiate class within constructor
If I instantiate several classes in a constructor, for example: public function __construct() { parent::__construct(); $this->loginModel = new \Application\Models\Login; $this->followModel =…
-
-2
votes2
answers48
viewsthis.Test1 is Undefined
I’m trying to move my application to the paradigm OO, but at the time of picking the value of the input is returned Undefined. I wanted to know the why that this error is made, and the…
-
-2
votes1
answer105
viewsHow to create a Constructor when there is if/Else and external variables?
I have several variables like this, that call an HTML element always with the same name: var $inputFromA = $(".inputFromA"); It’s at least 10: inputFromA, inputFromB, inputFromC… All these variables…
-
-4
votes1
answer81
viewsError with constructor
MyCircle c = new MyCircle(2,5,8);/// Instanciei um objeto no main. public class MyCircle { private MyPoint center; private int radius=1; public MyCircle(int x,int y,int radius) {…
-
-4
votes1
answer95
viewsWhat is the correct way to insert a necessary data into a constructor in PHP?
How should I place the parameters inside the constructor’s parentheses? I tried as follows as seen in videos but has the following error: OBS.: I am using the terminal, I am using the file…