Most voted "inheritance" questions
In object-oriented programming, inheritance is the system that allows objects to support operations defined by previous types without having to provide their own definition. She is the main vector for polymorphism.
Learn more…245 questions
Sort by count of
-
5
votes1
answer77
viewsHow to solve the code duplication problem?
In Wordpress I am creating a custom screen in the administration area. That’s why I’m extending my class customProductsListTable the class WP_List_Table: class customProductsListTable extends…
-
5
votes3
answers325
viewsIs it possible to override a base class property?
I have a class Cliente, which is the basis. In it I have the property Celular with Data Annotation "Required". I wonder if it is possible to use a property Cellular in class ClientePersonalizado,…
-
5
votes1
answer509
viewsPolymorphism in Typescript
I am creating my application with the following structure: An abstract class Person, and inheriting from Person, the classes PessoaFisica and PessoaJuridica, And finally, a class Cliente receiving…
-
4
votes1
answer161
viewsInheritance with interface
How could I solve the following problem. Setting: I have a class B that inherits from class A and implements interface I. Problem: The I interface requires the implementation of the X method which…
-
4
votes1
answer145
viewsHow to change the type of the persisted class in a legacy model using the Entityframework
I have the following class scheme with inheritance, as an example: public class Veiculo { public int Id { set; get; } public string Descricao { set; get; } } public class Moto : Veiculo { } public…
-
4
votes2
answers466
viewsHow to go through Arraylist with daughter class
Next, I have one ArrayList student type (which is an abstract class), and I have two daughter classes (EstudanteGraduacao and EstudantePosGraduacao), when I’ll add them to ArrayList it’s quiet, but…
-
4
votes4
answers7150
viewsIn inheritance with private attributes, does not the daughter class take its attributes from the mother class?
The devmedia article says the modifier private does not give access to its attributes in its child classes. It has a table with modifiers. In inheritance with private attributes, the daughter class…
-
4
votes2
answers658
viewsIn C++ what is the command corresponding to Java super()?
In Java: public class Teste extends Testando { private String nome; private int numero; public Teste(String teste, String nome, int numero) { super(teste); this.nome = nome; this.numero = numero; }…
-
4
votes2
answers1010
viewsDoes the use of traits replace the role of multiple inheritance?
What happens if I use in a class two traits different, and both have a method with the same name, but different implementations in this method?
-
4
votes2
answers180
viewsChange of object in inheritance
I have the following classes: class Funcionario { } class Coordenador : Funcionario { } class Gerente : Funcionario { } There a certain moment a Coordinator can become a Manager. How to solve this?…
-
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
votes1
answer270
viewsWhat is the difference between mixins and inheritance?
Conceptually, there is a difference between a class that extends a module by mixin and a class that inherits another class (unique inheritance)? I know why mixins, a class can extend multiple…
-
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
votes4
answers569
viewsIn Object Orientation, does an inheritance violate encapsulation?
According to the book Design Standards written by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides, make a statement: "...inheritance violates the encapsulation." Below is the paragraph…
-
4
votes1
answer232
viewsUse of Generalization/Specialization in Data Modeling
I’ve read some articles about Generalization/Specialization in data modeling, but some questions have arisen: Is the primary key to generalization also the primary key to specializations - that is,…
-
4
votes1
answer79
viewsIs it possible to force a method to be extended in Java?
It is possible to "force" a method to be extensible? The statement of the exercise says exactly this: we have to create a class, within it create a method and force this method to be extended. From…
-
4
votes1
answer79
viewsA list of a guy can’t pass as a list of his 'higher' type?
There are some entities in the application that I am developing that need to be sorted by a predefined routine. Thinking about it was created contract class, called ElementoOrdenavel and all…
-
4
votes2
answers540
viewsPHP POO error Polymorphism
When developing a simple PHP POO application, I came across an unexpected error, and I have no idea why. I’m starting now to study object-oriented programming and only have a small C-base#. The…
-
4
votes1
answer251
viewsGeneric and Comparable in Java
I have a question I can’t get answered, if anyone can give me a plausible explanation I’d be grateful. Assuming I have two classes: public class Figura implements Comparable<Figura> { private…
-
4
votes1
answer261
viewsHeritage in object-oriented programming
I was reading that article today and I came across the following statement: "Inheritance refers to the ability of an object to access methods and other properties of another object." Inheritance…
-
4
votes1
answer150
viewsHow to implement an abstract method with a generic class in C#
I am creating a functional Factory where I define what is its output type and what are the required implementation methods. With this implementation, when I try to use the object obj within the…
-
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() {…
-
3
votes2
answers103
viewsHow to capture Assembly from classes that inherit from a single class
I have numerous classes. All inherit from a single class public abstract class ClasseBase { public int Id {get;set;} } and other classes: public class Teste1 : ClasseBase{ } public class Teste2 :…
-
3
votes1
answer1169
viewsHow to create an object with class template?
I have this code: Main.cpp Warehouse<Base<int>> arm(1, 1, 1, 1); arm.createSubBase(1,1,1); Warehouse. h private: vector<Base<T>*> whouse; public : void createSubBase(int,…
-
3
votes3
answers606
viewsCorrect Inheritance in Entity Framework
I have a mother class DadosClientes and two child classes DadosClientesPF, and DadosClientesPJ. Instance DadosCliente has the field: Nome, Telefone Instance DadosClientePF has the field: CPF…
-
3
votes4
answers15572
viewsWhat is the super() function for;
I am studying Java and I need to understand the logic of a code here. I wanted to know what this piece of code does: public class UsuarioController extends HttpServlet { private DAO dao; public…
-
3
votes1
answer307
viewsUse of equals and inheritance
I have a parent class and in it I have a equals and I have other daughter classes of this father class and in them I want to overwrite the equals to compare particular attributes of these daughter…
-
3
votes2
answers122
viewsHeirs attributes with prototype do not appear in Javascript Reflection
I have the class Animal that has some properties that are enumerable: true, that is, I can list them via Reflection using for..in. So I have the class Coelho that has the attribute cor. How rabbit…
-
3
votes1
answer257
viewsInheritance with Repository Pattern
I’m studying and trying to implement the Repository Pattern in C# however I am having some difficulties in solving certain problems with inheritance among my classes of Repository, for example the…
c# oop entity-framework pattern-design inheritanceasked 10 years, 2 months ago Pablo Tondolo de Vargas 5,444 -
3
votes1
answer367
viewsWhat does equals(Object o) mean in this method?
In that code: public boolean equals(Object o) { Aluno outro = (Aluno)o; return this.nome.equals(outro); } What’s he good for?
-
3
votes2
answers12630
viewsHow does Java Builder Heritage work?
In Java when one class inherits from another it is necessary to initialize the constructor of the parent class, right? using the super() and passing to this super() the parameters the parent…
-
3
votes1
answer284
viewsHow to inherit methods from one prototype to another using the Node.js usel module?
I was watching the video of a guy explaining events of Node.js and at the end he makes a small module using util.inherit to inherit from one prototype constructor to another. Although I know the…
-
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
answer63
viewsReuse of code with web language
I’m working on three apps different ones that use Ionic and Cordova. The three are very similar at some points mainly in the layout. I wonder if it is possible to create a kind of library or…
-
3
votes1
answer149
viewsIn what order does a class inherit from its python superclasses?
Be the code below: class B(A): def __init__(self): self.c = 16 def y(self): print("B.y") def get_c(self): return self.c class C(object): def __init__(self): self.c = 5 def y(self): print("C.y") def…
-
3
votes3
answers107
viewsDoubt about class inheritance in Java
I have the following code one ebook who inherits the class Livro (superclass). However, I can’t create a new ebook and set in name, when I put the main method (main) makes a mistake. Class Autor:…
-
3
votes1
answer811
viewsIs it possible to return the child class through a method in the parent class?
I’m making a Builder and I’d like you to behave as follows: abstract class ClassePaiBuilder { public ClassePaiBuilder SetAtributo(string atributo) { // codigo return this; } public string Build() {…
-
3
votes3
answers1689
viewsHow to make visual form inheritance in Windows Forms?
I have a form base that will be the form 'Dad, with three buttons on it. Add, Delete and Change. I’m gonna use the formbase to standardize my registration screens, so each registration screen when…
-
3
votes1
answer277
viewsKnowing which class of daughter the parent class points to
I came from Java and I have a question about polymorphism in C++. Given these classes: class Empresa{ vector<Pessoa> pessoas; int empregados; addPessoa(Pessoa* p) } class Pessoa { ... }; class…
-
3
votes1
answer1080
viewsHow to remove all references from deleted acestras forms from the parent form?
I have my generic form and I have several others who have visually inherited its components. When I delete a component in the form father and open a heir get that message: I can click OK and confirm…
-
3
votes1
answer1173
viewsAsp.net MVC Models Heritage
I am trying to implement a person register where I have the inheritances for legal and physical person, but my saving method is not getting the type of person properly. follows example code…
-
3
votes1
answer994
viewsDifference between type inheritance and implementation inheritance
My teacher passed a booklet on Object Oriented Data Structure with Java and in the booklet there is an excerpt (without deepening) that says the following: "Interface promotes heritage of type and…
-
3
votes2
answers113
viewsClasses with inheritance and set method
I’m having a doubt, I’m developing a simple modeling with a superclass person and two other subclasses physical person and legal person. I’m confused about the SET method. I do not know if I should…
-
3
votes2
answers122
viewsWhen should I use generalization in case of use?
What is the purpose of generalization in the case of use? When should I generalize? If I have 2 actors, one student and the other teacher, they are respectively users, then enter the generalization…
-
3
votes1
answer219
viewsWhat is the "real" meaning of the key word 'extends' in Java?
First of all, I know how to use and work the keyword extends, my real doubt lies in the meaning of that word, more precisely because extends and not inherit or something like that? The only thing…
-
3
votes2
answers843
viewsOverwrite methods based on name only
I’m creating an abstract base class to provide a pattern for other classes. The base class methods shall be superscripted in the derived class. Now comes the cat jump. The superscript should happen…
-
3
votes2
answers220
viewsInheritance problem
I have a problem with a bank search, I will try to explain in the best possible and clearest way. I have a table Pessoa and a table Cliente, the last inherits from Pessoa, I also have a table…
-
3
votes1
answer998
viewsException class creation and implementation
I am having problems implementing an Exception class. The explanation of the program is: Vector strings must be initialized with "", not null. The vector capacity shall be capable of being changed…
-
3
votes1
answer462
viewsAlternative to multiple inheritance
It is not possible to inherit more than one class in C#, so I come here looking for suggestions for my problem. I am building a small game using Unity. In Unity the game objects (GameObject) inherit…
-
3
votes1
answer2575
viewsInheritance with builders
I need to create a base class animal and 3 other hereditary classes of other animals. Each class must have its own function emitirSom. They should be invoked polymorphically through a vector. I…