Questions tagged as 'classes'

2
answers

get_called_class or new static?

I do not remember which library in PHP I saw this, but there was a code snippet where, to get a new instance of the current class, the get_called_class function was used. However PHP has the keyword static , which refers to late...
asked by 03.10.2015 / 18:58
1
answer

In a console program in C #, where is the main class defined?

I'm doing my first console program in C #, just to do some testing. I have two classes: HelloConsole.MainClass and HelloConsole.Calc . I have the following code: using System; // Aprendendo o alias de namespace using C = S...
asked by 14.06.2016 / 18:37
1
answer

How to clone objects in Python?

In some languages, in addition to instantiating a class to construct a given object, we can also clone an existing instance, if we want an object with the same characteristics of the current instance, but without changing the original state. p>...
asked by 04.11.2016 / 11:33
1
answer

Why hide the implementation of a class?

This is the concept that I have tried hard to understand, but I have never fully achieved it. I'll take this excerpt from a Deitel book to illustrate:    It is better software engineering to define member functions outside the   class defi...
asked by 10.09.2017 / 16:30
1
answer

Access properties without knowing name

Is it possible within the class to access all your (properties) definitions without having their names? For example, if I create an instance of a class $classe = new Classe() , and I'm defining things in it: $classe->ComprarFile...
asked by 13.10.2015 / 03:18
1
answer

Calling an object while creating another object

I have a Person class and a Date class, the Person class creates a person the date class creates a date to use as the date of birth in the Person class, how is it that when creating a Person I create a date without having to use the code complet...
asked by 26.07.2016 / 23:43
1
answer

Performance differences between structs and classes

I know the difference of structs and classes is that structs has its public members by default, and that structs belong to C (but nothing prevents from using in C ++). In practice when creating an object for classes or a...
asked by 20.12.2017 / 12:09
1
answer

Correct Statement Classes Model MVC Ninject

I started using OO a short time ago and in all projects that I see on the net, I see the following way of declaration. public class Trabalhador { public int Id { get; set; } public string Nome { get; set; } public virtual ICollecti...
asked by 19.05.2014 / 01:55
1
answer

Data initialization of a class

Is there any class initialization function for C ++? In Lua, using the classlib library there is the __init function, and in Python as well. EX: require "classlib" Human = class(); function Human:__init(name, age) self.nam...
asked by 20.12.2014 / 01:26
1
answer

How to get attribute dynamically

How would I do the following PHP code in C #? class teste{ public $x = 10; public $y = 10; } $n = new teste(); $a = "y"; print_r($n->{$a}); Note that the dynamism is in the variable $a , in which if I change to x i...
asked by 23.12.2015 / 01:45