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
-
4
votes1
answer1041
viewsWhat is the elegant way to read this PHP Object?
I have the Result of a Webservice below, I’m doing a "foreachs" to read each level of the Class, but I think it should have a more elegant way to read and get the values of the object, follows the…
-
4
votes1
answer310
viewsAbstract class and C#properties?
Hello, everyone! Next, I created an abstract class called Tables, where classes of basic tables of the system will inherit from this abstract class. As Neighborhood, City, States, category, etc..…
-
4
votes2
answers607
viewsWhat is the difference between initializing a constructor or doing attribution within the constructor?
What is the difference between the two examples below? I should also assign the value within the constructor in this class even if I initialized? example 1: class sof{ int teste; public: sof(int t)…
-
4
votes1
answer64
views -
4
votes1
answer1193
viewsCreate class inheritance
I am studying object-oriented Java programming and need to perform the following exercise: Implement the class Funcionario and the class Gerente. Create the class Assistente, which is also a…
-
4
votes2
answers117
viewsCan separating static methods into several classes have a negative impact?
In question of organization it is relevant to separate methods into different classes. If we organize the methods in different classes in order to create a better organization, we can have a…
-
4
votes3
answers113
viewsHow to implement custom features in a model on . NET?
I needed to implement some features in the model users but as you can see early on this class is automatically generated by Entity, so whenever I upgrade or recreate the model the custom…
-
4
votes2
answers1117
viewsHow do I return a new instance of the python class itself dynamically inside it?
I’m giving a study in Python and for this I am building a class in Python that I had already done in PHP. For example, in a given method in PHP I needed to return the same instance of the class,…
-
4
votes1
answer68
viewsProblems to remove vector node
I have two classes: class CAlbum { private: QString Nome; /**< Nome do Álbum */ QString Descricao; /**< Descrição do Álbum */ QString Diretoria; /**< Diretoria onde se encontra o Álbum */…
-
4
votes4
answers100
viewsfunction_exists fatal error
Hello, I need help to solve this problem. I have the following code snippet (put the line number to facilitate): **186** if ( function_exists( self::$function_val() ) === TRUE ){ **187**…
-
4
votes1
answer325
viewsMethods with Dynamic C#parameter
I need your help with the following question. I have a data access class that has a method that takes the parameters to run a stored database. The problem is this, I have several objects in the…
-
4
votes2
answers287
viewsHow to add methods to a native class?
How to add functions in a native C#class, in my case I tried to do in System.Math only as a test: public class Math { public static double test(double a) { return a; } } And call it that:…
-
4
votes2
answers137
viewsIs it possible that a class attribute is the class itself?
I’m starting to learn C++ Object oriented, and I have to make an algorithm using chained lists. In C, I used a structure that had as one of the attributes a pointer to the structure itself. I wonder…
-
4
votes3
answers138
viewsIn structures (struct) is it necessary to use getters and setters or only in classes (class)?
It is necessary to use setters and getters in structures to maintain good practice or is needed only in classes?
-
4
votes1
answer38
viewsIs there a way to do these assignments more cleanly?
I have a class that should be started with a array property. $subscription = new CheckRenew([ 'custom_2_id' => 13, 'email' => '[email protected]', 'zip' => '90530000', 'number' =>…
-
4
votes1
answer424
viewsTwo classes mapping the same table with the Entity Framework
I’m trying to do the entity map two classes to the same table this is possible? Setting: Man identity this decoupled (Eduardo Pires' Master) from my domain and the presentation layer in the domain…
-
4
votes2
answers110
viewsIs it wrong to have a class with only methods?
Is it wrong to have a class with only methods? Or would it be better to use namespaces to hold office?
-
4
votes2
answers1091
viewsOperation of the new operator
I wanted to understand basically what the logic behind the objects of the classes that use the operator new for example, I have the following program in D: import std.stdio; class Hello { public…
-
4
votes1
answer75
viewsWhen to use local classes in Java?
I learned that it is possible to declare classes within blocks as methods, for example: void exemplo() { class teste { } } But when local classes come in handy?…
-
4
votes1
answer52
viewsDoes accessing a variable outside the scope of the class go against SOLID principles?
const clients = [{ username: "test" }]; class Validator { constructor(username){ this.username = username; } isUsernameTaken(username) { let usernames = []; clients.forEach((e) =>…
-
4
votes1
answer614
viewsPrinting all attributes of a class
I have the following class: class Usuario(object): def __init__(self): self.Nome = '' self.Email = '' self.SalarioBruto = 0.0 self.SalarioLiquido = 0.0 self.Cargo = '' self.Despesas = Despesas()…
-
4
votes2
answers93
viewsWhat are pre-specified classes?
Reading the wikipedia publication about POJO (Plain Old Java Objects), I came across the term pre-specified classes. I understood very superficially that perhaps these are the classes of…
-
4
votes1
answer83
viewsHow does the compiler know that class x is an extension?
In this example, I create a class extension method DateTime in the c#: static class DateTimeExtensions { public DateTime PrimeiroDiaDoMes(this DateTime data) { return new DateTime(data.Year,…
-
4
votes3
answers290
viewsHow to make compatible objects coming from two different classes, derived from the same interface?
I have an interface (I’ll call it ICliente) which is used as a contract between an application and a DLL. public interface ICliente { int Id {get; set;} string Nome {get; set;} ... } This interface…
-
4
votes1
answer45
viewsWhat is the purpose of using a name for Javascript class expressions?
When using a class expression nominee in Javascript as in the example, I did not understand how to access _Name, whether it is possible to use it: let Nome = class _Nome { constructor(_nome) {…
-
4
votes1
answer66
viewsFollow the OCP principle or use "instanceof"
The OCP principle preaches: "open to extension, but closed to alteration". To achieve this we need to abstract, because with an abstraction we can extend without needing to change the one that uses…
-
4
votes1
answer75
viewsCompilation error on non-static element reference
public abstract class Teste { public static final Teste IMPLEMENTACAO_1 = new Teste() { @Override public void executar() { teste1(); } }; public static final Teste IMPLEMENTACAO_2 = new Teste() {…
-
4
votes2
answers96
viewsA class is an instance?
Considering the example, one can say that p1 is an instance of Pessoa, which is the class: class Pessoa end p1 = Pessoa.new() # => #<Pessoa:0x00000001268ee528> However, it is not often said…
-
3
votes1
answer631
viewsHow to cast between base and derivative classes?
I have an exercise that says I have to create a foundation. This base has two derivatives. I have to cast the derived class(1) for the derived class(2) and the derived class(2) for the base class.…
-
3
votes1
answer442
viewsClass creation in C++
I am developing a project and need to create an internal class. I am obliged to create a . cpp and a . h?
-
3
votes2
answers134
viewssubtraction of two double properties[]
I have a class called functions.Cs I need to create a property that stores the initial X,Y and final X,Y values, I thought: public double[] PosicaoInicialXY { get; set; } public double[]…
-
3
votes1
answer716
viewsHow to communicate between classes?
I’m starting at Javafx and I’m having doubts. The main class creates an Hbox with a button. This button has the action of creating a TableView in the Center of bdPrincipal. Only they are in…
-
3
votes2
answers23592
viewsUsing a class function within another PHP class
I have two classes, which is the correct way to call a function of another class, the way below returns error class DB { public function __construct($user, $password, $database, $host) {…
-
3
votes1
answer265
views -
3
votes2
answers60
viewsInnerclass object is created at what point?
I have a class which contains an Innerclass, I wonder if at the moment I give new ClassePrincipal() Innerclass is also created?
-
3
votes1
answer1494
viewsPass variable value between Classes
I would like to pass the values stored in the variables of the Parte1 to the Parte2 to validate the highest entered value. PART 1: public class SEP_06_parte1{ public static void main(String args[]){…
-
3
votes1
answer2607
viewsCan I declare a builder in the child classes when the mother class is abstract and already has a builder?
My question is this: If I can declare a constructor in a class abstract and also in the child classes. And also how to access their values. For example: abstract class Animal { private $nome;…
-
3
votes2
answers105
viewsData does not appear on the page
I made an OO code in PHP. I used Mysqli for the database and WAMPSERVER as the server, in which I entered data for the table "category". The collation of the bank is "latin2_general_ci". No errors…
-
3
votes2
answers1093
viewsWhat allows Java to find out which is the main class in a . jar
How Java Does to Figure Out Which Main Class in a File .jar
-
3
votes1
answer562
viewsClass implementation in the header itself
In my object orientation studies, I have seen many say that in creating classes it is necessary to create a header, containing class, attributes and methods, and also another file cpp to implement…
-
3
votes1
answer2388
viewsAccess attributes of an object vector of another class using C++ pointers
I am doing a job for the college in which I have to put together a program to manage a restaurant that only makes deliveries the orders are made by phone and internet using object orientation and…
-
3
votes1
answer236
viewsWhat is the difference between __CLASS__ and get_called_class?
In PHP, I know two methods to display the name of the current class being called: through the magic constant __CLASS__ and function get_called_class(). Apparently, they both do the same thing. class…
-
3
votes2
answers52
viewsI believe my mistake is in the matrices, or type conversions, but how to solve?
I’m new to java and I have to make a tetris. In this class in particular, I create 2 control matrices to manage the positions of the pieces on the screen, but it’s giving error. Does anyone have a…
-
3
votes1
answer294
viewsHow to include the same class in multiple files?
Because I can’t include the same class in multiple type files like this: #include "familia.h" class pessoa{ private: familia *f; }; ----- #include "pessoa." class familia{ private: pessoa *p; };…
-
3
votes1
answer826
viewsVector and Classes, drawing and filling vector in Java
I am doing an exercise that is necessary to create a vector of 10 names, and that has 3 methods. The first method is called register,and has the function to fill the vectors, the second method is…
-
3
votes1
answer75
viewsWhen declaring an interface in the class, who should implement it?
class Gerente extends Funcionario implements Autenticavel { He meant that Gerente implements the interface Autenticavel, or Funcionario which will implement the interface?…
-
3
votes1
answer9873
viewsHow to create a class with attributes and methods in C++?
In Java I know how to do it, but in C/C++ it’s little different so how to create a class with attributes and C methods++? I am using Codeblocks. When I create a class in C++ it creates two files one…
-
3
votes1
answer193
viewsDifference between pointer vector for a class and vector for a class?
When is pointer to class will we have to allocate memory space? What is the difference between the following two statements and when they should be used ? Vector <class*> nameOfVector; Vector…
-
3
votes1
answer369
viewsWhen my class returns a modified new instance of the class itself instead of modifying it itself, is it a project pattern?
I’m developing a class that is a collection of values. In it I have several methods that filter the values contained in this collection. My intention is to return a new instance of this same class…
-
3
votes1
answer289
viewsWhat is the difference between using #include "stack. h" or using the class statement ?
Having these two classes in two files .h distinguished. a. h class um { //(...) }; two. h #include "um.h" //opcao 1 class um; //opcao 2 class dois{ public: void f1(um * p); }; What is the difference…