Questions tagged as 'instanciar-objeto'

3
answers

What is the correct option for instantiating a class in PHP?

What is the correct option for instantiating a class in PHP? Whereas the class is under discussion if you call Atleta : 1) $atleta=Atleta; 2) $atleta= new Atleta(); 3) $atleta= Atleta(); Which of the 3 options is...
asked by 09.11.2016 / 12:11
2
answers

Is it possible to instantiate a class without storing it in a variable?

I usually do this: $a = new MinhaClass($Parametro); Can you do this without creating the $a variable? Only with new ?     
asked by 31.12.2017 / 15:39
3
answers

How to know how many objects were instantiated?

In a Java application, how do I know how many objects in a class were instantiated? This doubt came to me by reading the article mentioned in the link below. Here is the excerpt that gave me the doubt:    2.4 - Connection Factory       At...
asked by 05.11.2015 / 13:49
3
answers

Infinite object?

I ended up doing something that made me curious: I created a following Cao class: public class Cao { String nomeDoCao = null; Cao caes = new Cao(); public void setName(String name) { nomeDoCao = name; } publi...
asked by 22.07.2014 / 02:48
1
answer

How to pass argument to Prototype object with prototype?

With this to do this: function Biscoito(sabor,marca,preco) { this.sabor = sabor; this.rodas = marca; this.preco = preco; this.mostrarAtributos = function(){ return sabor + ", " + marca + ", " + preco; } } va...
asked by 21.12.2014 / 21:39
2
answers

Use static Closures or Closures in PHP?

As of PHP 5.4, Closures , when declared within the context of a method of the class (other than static methods), automatically inherits the funções anônimas as a reference of the class that contains it. Example: class StackOver...
asked by 27.01.2015 / 13:07
2
answers

Differences when instantiating a class

Using PHP when instantiating an object I do it as follows: $obj = NEW my_class_exemplo; however the auto complete of netbeans always gives me the option to put with parenthesis like this: $obj = NEW my_class_exemplo(); Question...
asked by 22.01.2014 / 23:33
2
answers

Instance in Django model with problem

I'm working on a project with multiple apps. The department app model is as follows: from emails.models import GerenciarEmails class Departamento(models.Model): #modelo de grupos de disciplinas class Meta: verbose_name = 'Departamento'...
asked by 12.11.2015 / 19:42
4
answers

Different methods of creating an object

What is the difference between these two types of creation / instantiation of an object? Usuario usuario = new Usuario(); usuario.listar(); new Usuario().listar();     
asked by 22.10.2016 / 22:45
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