Questions tagged as 'construtor'

2
answers

Where is the class constructor in Python?

Definition of Wikipedia.    The builder is a method   which is generally responsible for allocating the necessary resources to the   of the object beyond the initial definition of the variables of   status (attributes). In Python the...
asked by 23.01.2016 / 01:26
1
answer

What is the utility / reason for the existence of new Object ();

While studying a little more about objects, I came across things like new String , new Number , etc. I was curious, and I went to learn. I understood the operation, although I have my doubts about the usefulness of them, since my...
asked by 13.09.2018 / 20:09
2
answers

What is the difference between initializing a constructor or doing assignment inside the constructor?

What's the difference between the two examples below? Should I also assign the value inside the constructor in this class even though I have initialized? Example 1: class sof{ int teste; public: sof(int t) : teste(t){} ); Examp...
asked by 02.12.2016 / 02:39
2
answers

Shortcut to create parameterized constructor

Is there any shortcut in Visual Studio, which creates a constructor, with all the attributes created in the class? class Alimento { public int ID { get; set; } public string Titulo { get; set; } public string SubTitulo { get; set;...
asked by 07.07.2015 / 15:47
2
answers

Ways to instantiate an object and declare constructors

In C ++ there are several ways to create a constructor and instantiate an object. But there are so many ways I'm confused by the difference of each one. Assuming I have the following class: using namespace std; class Carro { private:...
asked by 20.09.2015 / 18:02
1
answer

What is the real need of the "initialize" method in Ruby?

def initialize(nome = "Anônimo", salario = 0.0) @nome = nome @salario = salario end To make it clear, what I can not understand is the difference between whether or not to use this method in a class and for what purpose it is eventually us...
asked by 07.11.2018 / 12:21
1
answer

Inheritance with constructors

I need to create a base class animal and 3 other hereditary classes of other animals. Each class must have its own emitirSom function. They must be polymorphically invoked through a vector. It turns out I do not know if the builder...
asked by 26.09.2017 / 02:52
1
answer

Are methods and constructors the same thing?

Some sources say that constructor is a special type of method, while others say that constructors are not methods. Some people also say that although they are different from the JVM, they treat them the same way. After all, is a constructor a ty...
asked by 19.02.2016 / 19:20
1
answer

Differences in Constructors Using Property vs. Field

What's the difference between: namespace WMB.CieloB { internal class FuncoesCielo { internal FuncoesCielo(int iDC, Boleto boleto) { IDCliente = iDC; this.boleto = boleto;...
asked by 22.04.2016 / 14:31
2
answers

Java constructor with array

I'm learning about constructors in java but I stuck in the exercise of college that seemed simple, the proposal is to create a class constructor with an array, and call it in another class to attribulate the values to array: Builder: public...
asked by 22.03.2016 / 02:14