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
answer243
viewsInfinite loop in exercise using classes
I’m doing an exercise in Python, which is a game using classes. It happens that when it arrived in the room "Escapepod()" and I select the correct POD, the looping becomes infinite, not knowing the…
-
2
votes1
answer119
viewsIs it possible to implement an abstract class in PHP without the need for inheritance as in Java?
It is possible to perform the class instance in PHP "in the same way" CachorroAbstract in the method main down below: public abstract class CachorroAbstract { public abstract void latir(); } public…
-
2
votes1
answer83
viewsIn python, how can I simulate a read-only property in classes?
I would like to know how I can simulate a read-only property on Python. For example, I have the following code: class IPInfo(object): def __init__(self, ip): self.ip = ip; ip = IPInfo(object) ip.ip…
-
2
votes1
answer57
viewsDifference between List and and Return in Entity
Hello, I am with a doubt when I will take the data of an SQL query, there is the possibility to pull by list and by Entity, which is would be the "most correct" or the usability of each? public…
-
2
votes3
answers3134
viewsAdd or Remove Class from a DIV by clicking
Hello guys I’m wanting to make when I press 1x on DIV "packages . PA" it will make the changes: classify .select CSS: #bottaaoPA: Display:Block ; CSS: bottaaoPB: Display:None; CSS: bottaaoPC:…
-
2
votes1
answer265
viewsClass functions hook (offset)
I don’t know the right way to explain this question, but I’ll try it my way. I have an app. exe and I need to create some customizations for the executable, so I created a DLL and gave hook for the…
-
2
votes1
answer63
viewsIs there a way to create a private class in C++?
I wanted to create a class where it could be accessed in the library that I created, how do I declare the class as private and can be called only in the library?
-
2
votes2
answers909
viewsHow to use Operator= to copy a pointer vector?
Having this class, I would like to implement, operator =, copy the pointer vector to int for another vector, it is obligatory to reserve memory before doing so? What’s the difference between making…
-
2
votes1
answer426
viewsInstantiate class or use public methods?
When using a class method, there are two approaches: instantiating the class and using the method by the object, or making the method public static and call directly. Is there a problem using one or…
-
2
votes3
answers342
viewsWhere should I put a calculation method? In the entity itself or in the business class?
I have an architectural doubt, I believe. I need to create a method that receives a period of dates and an entity in which to execute a search in the period cited. In fact, to ask this question it…
-
2
votes2
answers2038
viewsHow do one class that is inside another inherit an instantiated variable from the last one in python?
See the following python script: class a: def __init__(self,n): self.n=n class b: def __init__(self): ## o que botar aqui para receber a variável self.n ## def show(self): return self.n…
-
2
votes3
answers410
viewsCall a method automatically via a partial class on . NET
I created a partial class to the model users where I implemented some custom functions, such as a function that takes the assigned name and surname and generates a handle, see in the following…
-
2
votes2
answers189
viewsWhat is class to draw circle on Android?
I know the Class Rect for rectangle and circle private Rect retangulo = new Rect(); What class to draw circle on Android?
-
2
votes2
answers96
viewsC++: File header not recognizing class
I am working with several classes, and to organize myself better, I put each class in a different file. actor. h #ifndef ACTOR_H #define ACTOR_H #include "SDL.h" #include <string> #include…
-
2
votes1
answer865
viewsPython to C++ conversion
I work on my course with C++, and wanted to use a Python class variable access feature. See an example: class Telefone: nums = {} def __init__(self, numero): self.num = numero Telefone.nums[numero]…
-
2
votes2
answers896
viewsStruct or Classes, huh?
I made the code using structure, I wanted to know if with classes it would be more efficient. I’m doing it in C++ Builder. The idea of the code and the following: create a list of problems, where…
-
2
votes1
answer55
viewsHow to send variable value into php class?
I have been perfecting the techniques of safe use with database connection and arrived at the script below. <?php class query_sql { protected static $conect; private function __construct() {…
-
2
votes1
answer77
viewsHow to tell whom a class will extend at runtime?
I have the class public class Conhecimento{} This class extends from another class "Cteproc" Only this Cteproc class has "versions" example. V200.Cteproc V300.Cteproc My problem is that in creating…
-
2
votes4
answers1502
viewsHow to inherit more than one class in PHP?
There is the possibility of inheriting two classes in PHP? I have a class that already inherits the class Usuarios and would like her to inherit the class Crud also. class Alunos extends Usuarios {…
-
2
votes2
answers248
viewsWhat is the best method to access a class member?
What is the best method to access a class member for speed and organization? class cMinhaClasse { public: void Funcao(int r); }; int main() { // Método 1 - Acessando classe por ponteiro cMinhaClasse…
-
2
votes1
answer1069
viewsHow to access variables from another class of objects per array?
I have two classes, : Route and Costs. Route : public double getKmPercorrida() { return kmPercorrida; } public void setKmPercorrida(double kmPercorrida) { this.kmPercorrida = kmPercorrida; } public…
-
2
votes1
answer2121
viewsHow to take variable value within a Function in one Class to another Function?
I have a class for Image Upload, and I want to get the value of a variable within a function calling for salvar()! I want to create a function called getNome() to get the name of the image with…
-
2
votes4
answers2255
viewsChanging CSS by class in Javascript, is it possible?
I wonder if it is possible to make changes to the CSS of a class by Javascript. We were able to get the Divs by id with the command document.getElementById("nomedaiddadiv");. Have some command that…
-
2
votes1
answer124
viewsClass organization
I need to create a system of posts. I’m having a hard time studying class and I’m wondering which of the two ways to use it: class publicarPost {} class excluirPost {} class curtir {} or class Post…
-
2
votes2
answers566
viewsHow to implement operator overload << and >> in C++?
Hello, I’m doing an exercise consisting of the following statement: Sorry to put a print, but I could not select the text and it would be unnecessary to type everything here. Finally, I made the…
-
2
votes2
answers143
viewsOverload of C++ operators, is the auxiliary variable necessary in this case?
I am studying for the book Introduction to Object-Oriented Programming with C++ (Antonio Mendes da Silva Filho), and implemented an example of it as follows: #include <iostream> using…
-
2
votes2
answers2906
viewsHow to add a class to an HTML element via Javascript. In my case, I need to add a class to the H1 element below
I need to add a class to the H1 element var div = document.createElement("div"); var h1 = document.createElement("h1"); var p = document.createElement("p"); h1.textContent = "Me Ajuda";…
-
2
votes0
answers1173
viewsHow to Create frame with text in the middle of the page?
How do I create boards equal to these , also with a little transparency ? I was kind of doing this basic job.…
-
2
votes1
answer184
viewsPOO in Java - World Cup Modeling
I am entering the universe of Object Orientation and, moved by curiosity, I decided to try to simulate the organization of a World Cup through these concepts. Well, I’m having some difficulties with…
-
2
votes2
answers871
views"java.lang.Nullpointerexception" error in Java
Good afternoon, I have an error on line 17 of main. I have a "Student" object and another "POO1" object. I have written the following code: Aluno aluno = new Aluno (); Avaliacao poo1 =…
-
2
votes3
answers1106
viewsClasses with associations in UML
I’m from the time of structured programming and now I’m returning and trying to fit in with OOP. I made a diagram below. I’m on the right track? I created this class Empresa thinking of not having…
-
2
votes2
answers359
viewsKeyword "new" in C#
I went to see about the keyword new in C#, but I could not find someone who explains well what I want to know. They say that the new creates a new instance, but I don’t understand exactly what they…
-
2
votes1
answer340
viewsHow to create Java constants?
A java constant cannot be changed, but can be assigned an initial value via another variable ? For example, if we have in our program a method that hypothetically calculates the import rate of a…
-
2
votes1
answer487
viewsHow to create this class hierarchy?
In this exercise, I have to create a class within another class or are independent classes? An animal contains a name, length, number of legs (default is 4), one color, environment and a speed (in…
-
2
votes1
answer3402
views"TS1005: ';' expected" error when compiling class with Typescript
I am studying Typescript classes through official documentation: https://www.typescriptlang.org/docs/handbook/classes.html. I used exactly the same example code as the documentation: class Greeter {…
-
2
votes1
answer196
viewsClass within class, is it possible? (Python)
I can include a class within another class (Father and daughter rsrs)? Reason for the question? Simple, in Django I saw something like this class Form(...): class Meta: (code) Okay, I looked it…
-
2
votes1
answer114
views -
2
votes2
answers201
viewsAssociative class with double dependency
I was searching the internet and saw this way of making association between Java classes. Is it correct to make this type of association? 'Cause I did a lot of research on the Internet and I…
-
2
votes1
answer169
viewsHow do you create an optional parameter in a class method?
I know that to create an optional parameter in a function you can do this: void exemplo(int a,int b=0); But how do I do it in a class function ex: class Exemplo{ public: void nada(int,int); }; void…
-
2
votes1
answer160
viewsHow does operator overload work?
How this code works? class MyClass: def __init__(self, *args): self.Input = args def __add__(self, Other): Output = MyClass() Output.Input = self.Input + Other.Input return Output def __str__(self):…
-
2
votes0
answers102
viewsWhy turn absolutely everything into Classes in PHP?
My systems both in ASP, Delphi and PHP maintains a kind of old standard (procedural) in the programming mode, because I find it boring to program as it is today, I see many or otherwise all using…
-
2
votes1
answer125
viewsDjango View class keeps values
A curiosity that has accompanied me for a long time in Django and I never managed to heal: Next. Let’s say I have something like: from django.shortcuts import render from django.views import View…
-
2
votes1
answer244
viewsPrivate class in C#
I have a class Pessoa.cs private, but I can call her in some other class, for example I created a class called Parametro.cs; I can instantiate the class private Pessoa without the slightest problem.…
-
2
votes2
answers99
viewsWhy is it necessary to instantiate a Python class when I can call it directly?
class People: def talk(): print('hello') p1 = People p1.talk() What is the need of instance it if I may call you directly? class People: def talk(): print('hello') People.talk()…
-
2
votes1
answer1893
viewsDoubt to create and work with JAVA class array
I have a program with 2 classes. The player class contains only the name attribute: public class player { String name; } And I have the Main Class that has the function below and the call of the…
-
2
votes2
answers648
viewshow to access the class array with jQuery? Take the second class of an element
I’m listing the icons from a list on console.log() they are displayed, however I want to capture only the second classes of icons in a variable, but I don’t know how to access with jQuery the second…
-
2
votes2
answers451
views -
2
votes1
answer807
viewsStable vs unstable sorting
What defines a stable sort algorithm? In this question has already been talked a little about what is stable and unstable ordering, but I still do not understand the advantage of using an unstable.…
-
2
votes1
answer52
viewsHow to make this class usable?
In the code below, I would like to return an instance of the class itself with the data filled through a text file. The lines are stored this way in the file: Yug…
-
2
votes2
answers73
viewsUse standard Form instance in another class
This is my class HotKey public class HotKey { private string nome; public HotKey(string nome) { this.nome = nome; } private void Start_KeyPressed(object sender, KeyPressedEventArgs e) {…