Most voted "abstract-classes" questions
An abstract class is developed to represent abstract entities and concepts. The abstract class is always a superclass that has no instances.
Learn more…47 questions
Sort by count of
-
57
votes7
answers1478
viewsIs using many interfaces a bad programming practice?
I am a student in Information Systems and I am modeling a game, a virtual pet that has its needs and conversation with its owner, below follows the modeling of classes and interfaces. I showed it to…
oop software-architecture interface abstract-classesasked 10 years, 4 months ago Ivan Ricardo Lopes 1,376 -
49
votes6
answers32712
viewsAbstract Class X Interface
What is the difference between an abstract class and an interface? I don’t understand when I should use one or the other.
-
36
votes6
answers34111
viewsWhat is and what is an abstract class for?
In object orientation, what is the meaning of an abstract class? What is its purpose?
-
30
votes2
answers4104
viewsWhen should I use Inheritance, Abstract Class, Interface, or a Trait?
From PHP 5.4 we have the Trait, that "are mechanisms that help (and greatly) the reuse of code, and serve perfectly to solve the problem of lack of multiple inheritance". Example of Abastrata Class…
php interface inheritance abstract-classes traitasked 9 years, 4 months ago Wallace Maxters 102,340 -
17
votes4
answers2589
viewsIs it possible to create an 'abstract class' in Javascript?
When creating a Javascript class whose attributes and methods are all static (for example, for storing preset settings for a game), I wonder if it is possible to define the class as abstract in a…
-
13
votes1
answer568
viewsWould it be right to leave the attributes of the abstract class as private or protected?
I don’t know how I should leave these attributes.
-
12
votes1
answer950
viewsJava Interface 8
Java 8 allows you to implement methods in the interface itself. So I’d like to know what an abstract class can do that an interface cannot. Source:…
-
10
votes3
answers2035
viewsInterface or Abstract?
I read several contents on this subject, until arriving at this example: public interface Funcionario{ public void trabalha(); public void recebe(double salario); } public abstract class Geek…
java oop software-engineering interface abstract-classesasked 10 years, 1 month ago Franchesco 5,144 -
8
votes1
answer716
viewsShould I extend from an abstract class or a concrete one?
When I need to extend a class, following the concept of Object Orientation, should I extend my code from an abstract class or an abstract class? What is the best practice to join?
-
6
votes4
answers640
viewsJava abstract class exercise doubt
I would like to ask for your help again in this exercise. This time using the abstract class. Create an abstract class FuncionarioAbstract with the attribute String name and abstract method: public…
-
5
votes1
answer75
viewsIs it possible to hide a public method from the abstract class?
I have the following scenario: public abstract class ClasseA { public string[] MetodoC(string parametro, string nomeObjeto) { // ações metodo } } public class ClasseB : ClasseA { public string[]…
-
5
votes1
answer158
viewsHas some real use when implementing non-abstract methods in an abstract class
Have some real use when implementing a method that has a field, (implemented code) in an abstract class that cannot be instantiated, since no compilation error occurs? public abstract class…
-
4
votes2
answers1077
viewsImplement abstract method in Python inheritance
Be the following class hierarchy, where class "A" has an abstract method called "foo": # -*- coding: utf-8 -*- import abc class A: __metaclass__ = abc.ABCMeta def __init__(self): pass…
-
4
votes2
answers1128
viewsWhat does an abstract class type variable mean?
Studying Pattern design I saw something that I didn’t understand very well what it means, when we have a variable of the type of an abstract class what it means exactly? Example: ClasseAbstrata…
-
4
votes2
answers197
viewsWhen to use Factory in abstract classes?
Abstract classes are classes that cannot be instantiated and their implementation depends on other classes, but using the keyword Factory can "instantiate" an abstract class. So, how and when to use…
-
4
votes1
answer53
viewsAre there abstract classes in Python?
I’m a beginner in Python and would like to know if there are abstract classes and methods in Python, if there is someone can give me an example? When I studied Java there were these classes to…
-
4
votes1
answer38
viewsUse of delete in an abstract class pointer
Reading the book A tour of C++, in a section on memory leakage, when I came across 3 statements regarding the code below: The implementation of Smiley may fail to delete pointer to mouth. The…
-
3
votes2
answers103
viewsHow to create a vector2 in C?
I wonder if there’s a way I could create a class, to store 2 variables, for example, a Vector2, where I would instantiate and use it like this: Vector2 tile; int posX, posY; posX = tile.x; posY =…
-
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
answers918
viewsHow to cast a typed class in C#?
I own the class Carro who inherits from the class Objeto and another class CarroTeste implementing the abstract class TesteBase that by its implements the interface ITeste, both (TesteBase and…
-
3
votes1
answer3315
viewsEnsure that generic object passed as parameter is subclass of an abstract class
First I would like to say that my doubt is not specifically about "verify that a generic object passed as parameter is subclass of an abstract class.", but I couldn’t pick a better title. If you…
-
3
votes1
answer454
viewsShould I use abstract class or interface?
I have a class that connects to Windows machines. I’m making it a little more generic so I can repurpose it to other systems. Soon I was able to identify four methods "generic": connect status…
-
3
votes1
answer134
viewsVariables and methods in the abstract class, where to put?
Cliente and Fornecedor has name, phone and email in common what is the best way for me to treat this, should I create these variables in common in the abstract class? or is there a better way for me…
-
3
votes2
answers202
viewsHow to prevent a class from being instantiated in Python?
I have a mother class and want to inherit it to a daughter class. But the mother class cannot be instantiated, only inherited. In other words, the mother class should be abstract. Although Python’s…
-
2
votes3
answers346
viewsHow to make a polymorphic pointer with the this pointer in the parameter?
For example, in Qt (correct me, if the logic is wrong, I haven’t touched Qt in a while), you can do this: QLabel label = new QLabel(this); Now let’s suppose: #include <iostream> class…
-
2
votes2
answers439
viewsStore modified class properties
I need to have stored in the class itself a list with (name and value) of the changed properties. However, I don’t know if the form I am using is feasible. I have the class Employee below: public…
-
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
answer183
viewsLINQ to SQL with entities that already exist, inheritance and composition
I’m starting to study LINQ to try to implement a project I’m working on. For examples both in articles as in videos, LINQ has an interface in visual Studio that generates the entity classes from the…
c# inheritance abstract-classes linq-to-sql compositionasked 8 years, 7 months ago Matheus Saraiva 2,157 -
2
votes1
answer421
viewsDefining an abstract attribute in a non-extabstracted class
I want to be able to instantiate an employee class (so this can’t be abstract) and have an abstract salary attribute that will be static for each type of employee. I can do (in the working class):…
-
2
votes1
answer103
viewsPHP: Interface type attribute
I’m doing a study of Project Standards. My first standard is Strategy, where I have an abstract class that has two attributes that should receive instances of a class that implements a certain…
-
2
votes2
answers183
viewsHow to resolve "There is no default constructor in ..." error in Java?
I have an abstract class called Veiculo which has two builders: public abstract class Veiculo { // Atributos ... public Veiculo(Marcas marca, int velocidade){...} public Veiculo(Marcas marca, int…
-
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
answer59
viewsHow to define a subclass of an abstract class so that it is concrete
With these classes: class SerVivo { public: virtual void funcA() = 0; virtual void funcB() = 0; }; class Vegetal : public SerVivo{ public: virtual void funcB(){ cout << "funcB em Vegetal \n";…
-
1
votes0
answers491
viewsQuestions about Abstract Classes and Interface (java)
Before I express my doubt it is valid to make clear that in a certain way I understand the difference between the two. I know that a abstract class can have implemented methods, attributes,…
-
1
votes1
answer1729
viewsHow do I inherit an abstract class in C++?
In Java we have the possibility to create abstract classes, but without the possibility of instantiating them, but we can create and instantiate a class that inherits the attributes and methods of…
-
1
votes1
answer512
viewsAbstract classes in Python
The method __subclasscheck__ should be defined at metaclass level, whereas the method __subclasshook__ can be defined as a class method provided that the class has as a metaclass ABC (or one of its…
-
0
votes2
answers273
viewsAbstract unit tests
I am having a problem using abstract classes to keep the common code of my tests, shutdown boot etc... I use a concrete class only to initialize the variables. The code inherited from the abstract…
-
0
votes3
answers262
viewsHow to instantiate a model and get its features by its name in Ruby on Rails
Since I have the abstract class User, and its sub-classes Client Employee and Admin, would like to render screens according to the chosen subclass. So: users/_form.html.erb : shall contain a…
ruby-on-rails ruby mvc abstract-classes instantiate-objectasked 9 years, 10 months ago user5020 1,027 -
0
votes1
answer96
viewsHow to run methods of all classes extending an interface on symfony
I needed something similar to that console doctrine:fixtures:load in relation to class DataFixtureLoader and the interface OrderedFixtureInterface that is, I want to make a Command where it searches…
-
0
votes1
answer157
viewsInheritance of abstract form
I have a standard form, with a textbox, a search button and a grid; as I intend to use it for several searches, I left an abstract Search() method and at the same time the form as abstract... When…
-
0
votes1
answer106
viewsError while trying to add everything together through a Java class
I’m doing a small project on expense control, I’m with a class called Expense which is an abstract class, and other classes called Transport,Feeding and Daily will inherit from it the total value of…
-
0
votes1
answer382
viewsTake a class that has a certain interface implemented in Generics
Hello. I want to do something like metodo(Class<? extends ClasseAbstrata> classe), only that of an abstract class, I want to use a interface, but I’ve moved on from extends for implements the…
-
0
votes0
answers57
viewsobjects sharing the same copy of a variable
The goal is to put into practice the contained concepts that I am learning in MALA GUPTA, 2015. So the way I’ve found to contribute is to ask the community to actually implement the concepts. So who…
-
0
votes1
answer95
viewsIn Java, getter and abstract Setter is correct?
I have an abstract parent class Usuario. And a daughter class Usuario_Adulto. The attribute idade is in the abstract class Usuario. To validate it I made a method Setter abstract in the parent…
java inheritance polymorphism abstract-classesasked 4 years, 4 months ago MARCOS DAVID ALMEIDA DE SOUSA 3 -
0
votes1
answer132
viewsForce the implementation of a certain type of abstract method
In the Python it is possible to define classes abstratas and métodos abstratos slightly simply, for example: class Spam(ABC): @abstractmethod def grok(self): pass This class cannot be instantiated…
-
0
votes3
answers418
viewsC# - No argument provided that corresponds to the required formal parameter in abstract class code
There’s a error of arguments provided in 3 constructors of my abstract class code, where the method get() must be written in the child classes of the employee class which are the classes…
-
-3
votes1
answer75
viewsHow to instantiate an Abstract class in C#?
I know the class abstract cannot be instantiated. But I need to call it in Windows Forms and I’m not getting it.