Most voted "classes" questions
In object orientation, a class is a structure that abstracts a set of objects with similar characteristics. A class defines the behavior of its objects through methods and possible states of these objects through attributes. In other words, a class describes the services provided by its objects and what information they can store.
Learn more…715 questions
Sort by count of
-
2
votes1
answer43
viewsHow do I compare one object type parameter to another (java)
I have the addCurso method that receives a parameter that is a course type object, it has information such as name and area, all within the College class, which has a vector where these courses will…
-
2
votes2
answers147
viewsObject Array (not objects) in Java - How to use
Hello, I have the following task to do: I have three types of employees (Commissioned, Salaried and Hourly) and I have to add them to a list (ArrayList) to manage them. ArrayList<Commissioned>…
-
2
votes1
answer92
viewsList private properties
I have the following class: class Orcamento{ private $valor; private $itens; public function __construct($valor){ $this->valor = $valor; $this->itens = []; } public function __get($property){…
-
2
votes4
answers428
viewsHow to validate data passed to a constructor?
Is there a way to handle possible errors or validations by instantiating a class using the constructor? For example, this is my constructor: public boolean ContaFisica(int agenciaConta, int…
-
2
votes2
answers177
viewsWhy can’t you access a class attribute in the inherited class?
I have this class: package auladezoitodonove; public class Conta { // atributos private int numeroConta; private String nomeCliente; private int identificador; //Construtores void Conta (){…
-
2
votes0
answers144
viewsI need to fix my Python Graph class to simulate a dictionary
Hello, I am trying to fix my graph class to use as a dictionary further forward, but from what I understand it is only accessing the memory location instead of the data, in the example below I will…
-
2
votes1
answer164
viewsIn what order to dispose the methods of a Java class?
In which order to dispose the methods of a Java class? Whereas a class can have: constructors, static methods, private methods, public methods, abstract methods. For example: public class Classe {…
-
2
votes1
answer35
views -
2
votes1
answer39
viewsHow do I access an attribute(which is a list) of a class by a method outside that class in python?
I have a Shop class that one of her attributes is a list (self.products = [ ]). class Loja(Empresa): def __init__(self, nome, cnpj, razao_social): super().__init__(nome, cnpj) self._razao_social =…
-
2
votes1
answer69
views -
2
votes1
answer65
viewsPython - Object-Oriented Programming
I created a module with two classes: I want to use both as if the mouse depended on the computer. E.g.: when using them: only when the Computer is turned on does the mouse have permission to turn on…
-
2
votes0
answers69
viewsAre there advantages or disadvantages between using closures or classes to achieve Javascript dependency injection?
Let’s say I have a function that depends on a logger to work. To follow the "good practice" and achieve a certain level of decoupling, I decide to make use of dependency injection so that this…
javascript classes software-architecture dependency-injection closuresasked 3 years, 9 months ago Luiz Felipe 32,886 -
2
votes3
answers104
viewsSyntactic difference between classes and constructor functions in Javascript?
I’m studying Javascript and I noticed that, in the constructor functions, we can declare variables and constants. For example: function Teste() { const nome = 'Bruno'; this.nomeAtributo = nome; }…
-
1
votes1
answer754
viewsHow can I pass a class value to a Listbox
I am involved in a small personal project, composed of some classes and many photons. I need to send a value that is obtained when I access a certain button, to the listbox that is in one of these…
-
1
votes4
answers1237
viewsAccess config.php variables
I am a beginner in php and I have a problem, I have a config.php file this way: <?php $config['dbHostname'] = 'localhost'; $config['dbUser'] = 'teste'; $config['dbPassword'] = 'passteste'; But I…
-
1
votes1
answer516
viewsHow to pass data(string) from a class to Viewcontroller’s Textfield
I want to pass data of a class of the type NSObject to be shown in my TextField Viewcontroller. I tried to use the function prepareForSegue but I couldn’t. Does anyone know how to pass the data,…
-
1
votes1
answer226
viewsExtend Tclientsocket Delphi class
I would like to know how to extend the Tclientsocket class in Delphi, to put new features without losing the old ones, with examples. Hug.
-
1
votes1
answer1525
viewsMap columns of separate tables into a single object and vice versa
Situation 1 I have the following tables, very simple: ....................... And I have the following classes: Client: @Entity public class Cliente implements Serializable { private static final…
-
1
votes1
answer556
viewsPOO with PHP $_POST
How It Should Be Done for a Super Global $_POST Value To Enter a Class. I’ve tried several ways, but without success. This value will be dealt with within the class.
-
1
votes1
answer59
viewsGet Type from a class without instantiating it
I need to get the Type of a class without instantiating it, I tried to do that way: variavelQualquer.Type = new ClasseA().Type; // Type é uma variável pública que guarda o valor do método GetType()…
-
1
votes3
answers4033
viewsUndefined reference compiling with g++
I usually use g++ to compile my code, but now that I’ve started learning template I cannot compile for anything, the following error appears: g++ -c pilha.cpp pilha-infinita.cpp g++ pilha.o…
-
1
votes1
answer3521
viewsDiscover the object class in Java
I have a set of functions to configure a set of parameters in Java like this: public void Util.setParametros(Integer par) {} public void Util.setParametros(String par) {} public void…
-
1
votes2
answers170
viewsHow to edit a Partial Class?
I took a project from a client, and there’s a class that’s on a partial. When I click to go in the reference opens the file, but in the project I can’t find the file, and has the following text in…
-
1
votes1
answer652
viewsHow to use a variable within another method of the same class?
How could I use the method define_title() the variable $extension that is within the method file_verify? class Title extends Imoveis { public function file_verify($file) { $file = explode("/",…
-
1
votes2
answers194
viewsInstantiate class in a library by method in the Norwegian
I have this line of code, and in it I have 2 methods, where one sets up the keypad and another takes the key pressed. void Maleta::setKeypad(int r1, int r2, int r3, int r4, int c1, int c2, int c3,…
-
1
votes2
answers100
viewsI define a value in a class, when I instate the same value is another
This is the code where I defined a class Animal is a breeding method that asks the species of the animal and defines its state as alive: public class Animal { public bool estaVivo, usaDrogas =…
-
1
votes1
answer269
viewsAdd sub property dynamically
class ObjetoSimples{ var $nome; var $cargo; var $turno; } class ObjetoComposto{ var $nome; var $setor; var $equipe; } How to add new nome with turno and cargo in equipe? For example:…
-
1
votes1
answer42
viewsDoubts about the use of class
Good morning, you guys. How are you? I am writing a windowsform application, and in some situations I need to make several queries, Insert and delete.. well, so I created a query class, a delete…
-
1
votes1
answer60
viewsCall class function: Minpdo::connect();
I have a class called MinPDO and within it a function called connect: class MinPDO { public $sgbd = "mysql"; public $dbhost = "localhost"; public $dbname = "minpdo"; public $dbuser = "root"; public…
-
1
votes1
answer431
viewsHow to send attributes to extended classes?
class Veiculos { protected $tipo = "carro"; } Below I am trying to identify which type of vehicle the class Veiculos assigned. I created a function tipo_veiculo that should show the user what type…
-
1
votes1
answer566
viewsHow to get the Return of a method that depends on another within a class?
I’m using a class called Semelhantes that will have 2 methods. The features magpie 3 characteristics of the current property through the id. The resemblant rides a query which aims to bring…
-
1
votes2
answers287
viewsCreate product classes and photos and initialize
I have a class Produto and within that class I have a class Categoria and a Class Foto. 1 Product may have only 1 category, but may have multiple Photos. The problem is with the photos. I did so:…
-
1
votes2
answers376
viewsStatic method calling an object
Because PHP allows me to use it like this, as below, the script runs normally. Wouldn’t it be incorrect? Or not? The aperador :: Isn’t it just for static methods? I was trying to access an object by…
-
1
votes3
answers717
viewsHow to list files in a directory?
I use the following code : $path = 'pasta_desejada'; $dir = new DirectoryIterator($path); foreach ($dir as $fileInfo) { $ext = strtolower( $fileInfo->getExtension() ); if( in_array( $ext, $types…
-
1
votes0
answers32
viewsUpload files not loading extension
Hello, I’m trying to generate the filename upado in md5();, but my file extension does not work at the time of upload, follow my class: <?php class Upload { private $_SupportedFormats =…
-
1
votes1
answer337
viewsHow to create an abstract class in C++?
In C++ virtual uses file . cpp #ifndef TETES_H #define TETES_H class Tetes { public: Tetes(); virtual ~Tetes(); virtual void exibeDados(); protected: private: }; #endif // TETES_H file . h #include…
-
1
votes1
answer272
viewsDo php’s autoload functions make an object available to any part of the site in the same session, even in different subdirectories?
I intend to make my code cleaner and therefore avoid using include or include_once all page start. I would not like to use frameworks that already do this work as Windows for example. I want to…
-
1
votes0
answers485
viewsCall to a Member Function prepare() on null in
I got this class that connects to Mysql through PDO, in this link. It works just fine. But I decided to turn it into a static class. And here’s the modified code. class db { private static $dsn;…
-
1
votes1
answer118
viewsGeneric vector with error
I’m concluding this generic vector activity, but I’m having trouble returning the last and first element of the list. and to remove the element. public class Vetor<T>{ T[] vetor; int…
-
1
votes1
answer61
viewsHow do I concatenate a variable into a class with Static function?
Guys I’m having a problem, I have function that when passing card number returns the flag name (visa, Maxcard etc) And I need to return the flag name within a Statica function $bandeira =…
-
1
votes2
answers261
viewsInheritance in the Entity Framework
I am now reading about cross domain inheritance in EF. I came across this example: public abstract class BillingDetail { public int BillingDetailId { get; set; } public string Owner { get; set; }…
-
1
votes4
answers110
viewsWhy this division in the class instantiation in C#?
In the book "Use the Head - C#", the author declares classes in a way that I did not understand their usefulness, according to the example: public partial class Form1 : Form { Farmer farmer; public…
-
1
votes1
answer225
viewsAssociation of various classes in Java
The project consists of a management system for a carrier, where an administrator manages travel, and these trips have drivers and trucks. I used association to relate the classes, but I’m having…
-
1
votes2
answers63
viewsProblems in a crud class
I’m trying to build a class to be used with mysql at first I have only two files so I’ll paste the code I’ve already done here and explain my doubt. classes/connect.php <?php /** * Created by…
-
1
votes1
answer442
viewsWhat is the difference between a state (State Machine) and a class?
Would you like to know how to differentiate a state, an interface of a class, what are its main differences? How can I distinguish them?
-
1
votes1
answer318
viewsWhat does it take to learn specific classes and methods for a task?
What I need to learn about classes and methods in general for Java and Android programming? For example: if I need to display a PDF, as I’ll learn to do it? We know that there are several classes,…
-
1
votes2
answers737
viewsHow to use one class functions in another?
In a project I was using a class to define functions for the entire project, and as the project is growing the need arose for the creation of a new file with new class and function. In this case I…
-
1
votes2
answers849
viewsCatch instance of daughter class
I have a class: class Children extends Database Soon, Children is the daughter class and Database the parent class, in the parent class I have the attribute: protected $object = null; The value of…
-
1
votes1
answer58
viewsC++: Instances of the same class
I have in a project a class Collision, and to make detection more efficient, wanted to have access to all instances (objects) of that same class. Is there any easy way to do this? Edit 1 I did this:…
-
1
votes3
answers2171
viewsJavascript function when clicking on any class="foo"
I have a calendar where every day is: <a class="dia" href="#">(Número do dia, ex: 1, 2, 3, etc)</a> Then I need that whenever the class "day" is clicked it calls a function, for example…