Questions tagged as 'construtor'

2
answers

PHP builders [closed]

Can not create 2 constructors for a class. How do I instantiate a class and use its functions without having to create a new object? In C #, for example, I use an empty constructor and I can still use one with parameters.     
asked by 14.06.2018 / 19:25
1
answer

What is the name of this part of the code?

Let's say I create a class ... public class Teste1 { public void Teste1(){ System.out.println("Olá"); } public void teste2(){ System.out.println("Oi"); } } Teste1 is...
asked by 11.04.2017 / 23:28
1
answer

Get instance of child class

I have a class: class Children extends Database So, Children is the child class and Database the parent class, in the parent class I have the attribute: protected $object = null; The value of it should be the instance of...
asked by 06.07.2016 / 20:16
2
answers

How does creating an Array work?

When using the new() command to create any object, we call the constructor of that object's class and get the reference to the created instance. However, what happens when creating an Array? Where do you point to (I know this term is i...
asked by 14.03.2016 / 13:11
1
answer

How to implement a copy constructor for a two-dimensional array in C ++?

I have the following situation: a Matriz class implemented as follows: Header: #ifndef MATRIZ_H #define MATRIZ_H class Matriz { public: Matriz(unsigned int nL, unsigned int nC); ~Matriz(); Matriz& ope...
asked by 29.09.2017 / 17:30
1
answer

The correct one is not to connect the bank only once and then go through the records?

<?php class Usuario { private $login; private $senha; private $admin; //variaveis internas private $bd; //conexão com o banco private $tabela; //nome da tabela public function __construct() { $this->bd...
asked by 11.03.2015 / 05:59
1
answer

Default constructor to calculate an employee's annual salary in C #

I need to make a code that calculates the annual salary (% with%) from the months worked ( float ) and monthly salary ( int ), but it has to be using the constructor method. Here is a code that I did but is returning 0 for the annu...
asked by 16.10.2018 / 15:58
1
answer

What's the difference between initializing a variable in these constructors? And how to put a constructor as default?

Is there any difference in initializing a variable in any of these forms of constructors? And how do I put a constructor as default ( default ) in a class that has more than one constructor? Builder 1: class Teste { private: int valor1,...
asked by 30.10.2017 / 15:04
1
answer

How to pass the class (Test2 test2) as reference in the ("super") C ++ constructor?

Based on this response In C ++ which the command corresponding to super () of Java? Class Teste2{ int x; int y; public: Teste2(int x, int y){ . . . } } class Testando{ Teste2 *teste2; public: Testando(Teste *teste2) {. . . . class T...
asked by 27.03.2016 / 21:51
2
answers

POO JAVA - Doubt Exercise

Well first follow below the exercise:    Create a class named Date that includes three pieces of information as instance variables:   a mês (tipo int) , a dia (tipo int) and a ano (tipo int) .       Provide a method...
asked by 07.03.2018 / 18:12