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
-
3
votes2
answers334
viewsIs "inheritance" table a bad practice in this case?
In my database I need to store employees, customers and suppliers. Since all these share data in common, but not all the data, I decided to create a table pessoas with the columns in common: id //…
-
3
votes2
answers84
viewsUsing interfaces for domain classes
Is it good practice to make use of domain class interfaces? Do I have an advantage in doing so? If so, which one? Example: public interface IAuditoria { long AuditoriaID { get; set; } string…
-
3
votes1
answer118
viewsCompiling an inherited class in C++ gives constructor error
I need to create a class for chess pieces. I created the class Peca and her derivative, Bispo. When I try to compile the bishop class, the compiler returns reset error. How can I resolve? #ifndef…
-
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
votes1
answer56
viewsWhat is the reason for using "super()" before creating daughter class variables?
I found this question which speaks almost of the same subject but her focus is on access to parent class methods. And my doubt is to know why the use of super() before the declaration of variables…
-
3
votes2
answers164
viewsUpcasting and subsequent downcasting allows you to access the attribute of the original type?
When I make a upcasting, object 1 will be converted to its supertype and an object 2 is created When object 1 is instantiated before doing the upcasting, has attributes that do not exist in the…
-
3
votes1
answer64
viewsWhat is the access modifier of an explicit implementation?
I created an iterator class that implements the interface IEnumerable<T>, implementing the interface IEnumerable. To make the implementation correctly, it is necessary to explicitly implement…
-
3
votes1
answer48
viewsUnable to initialize a generic object with inheritance
I’m having a hard time accepting an inherited class as a generic class type. public class Teste { private void Testando() { var dog = new Cachorro(); dog.Nome = "Toy"; dog.Patas = 4;…
-
2
votes2
answers211
viewsDoubt about inheritance in classes
How to do the if controller return TRUE or FALSE in accordance with the check() of the Validator? Currently it returns boolean to the validate();, but I wanted it to continue until the end of the…
-
2
votes2
answers238
viewsReturn values through a class derived from the same Parent
I have classes 1, 2a and 2b, where 1 is the main class, while 2a and 2b extends class 1. It is possible through class 2a to access values of class 2b directly or through the parent class? Basic…
-
2
votes1
answer332
viewsInheritance in Database
I am developing an application, where I have 3 tables that have the same attributes, but as they had attributes in these tables that were mandatory for some, and not for others, I decided to…
-
2
votes1
answer1330
viewsInheritance with jpa
Hello, I have a class called Usuario that is abstract and I have the class UsuarioComum and Administrador which they inherit from Usuario, I am using JPA annotations to generate the automatic…
-
2
votes1
answer250
viewsImplement parent class
Well, I’ve done a lot of research, I have a sense of how it works, but I couldn’t implement it, I’d like a light. I have the classes House and Building, I need to create a father class Immovable,…
-
2
votes1
answer67
viewsShould all inherited attributes be used?
I am constructing a class diagram, where several classes have 3 equal attributes, and one or another class has only 2 of these attributes. So I thought I’d create a parent class with all these…
-
2
votes0
answers54
viewsError creating a method in a legacy WFA application and polymorphism
I created a WFA project that will serve as a basis for the others, follows the description: I created a Formbase that has public control variables, such as operator name, date and time of access to…
-
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
votes1
answer1104
viewsTake and display data from a class attribute (class association)
I’m having a little trouble picking up a value from an attribute of the type class. Classe Pessoa public class Pessoa { public string Nome {get;set;} public int Idade {get;set;} public virtual void…
-
2
votes1
answer407
viewsMulti-table heritage in Laravel
I have an entity Resource, which in turn has several implementations, for example, VideoResource and MarkdownResource. Resource has several properties shared, the other two examples in turn have…
-
2
votes2
answers973
viewsInheritance X Composition - Mysql C# Entity
There was a doubt of inheritance modeling in C# involving the entities Pessoa, Pessoafísica and Pessoalegal, but Gypsy Morrison Mendez helped a lot! Now I have another question in another type of…
c# asp.net-mvc entity-framework inheritance compositionasked 8 years, 8 months ago Felipe Bulle 387 -
2
votes1
answer797
viewsOrder of class initialization/instantiation
class Bird { { System.out.print("b1 "); } public Bird() { System.out.print("b2 "); } } class Raptor extends Bird { static { System.out.print("r1 "); } public Raptor() { System.out.print("r2 "); } {…
-
2
votes1
answer286
viewsInstantiate annotated class with Hibernate inheritance using CDI
Good afternoon, I’m creating a project using JSF, CDI, Bootstrap and Hibernate. I would like to know how to work with the following problem, I have created a set of classes to represent a person…
-
2
votes1
answer154
viewsDoubts about class composition or inheritance
I’m having some doubts in that composition between the ClienteJuridico and Clientephysics with the NotaFiscal. I did some research and saw that the objetos of these classes within another, in case…
-
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
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
votes0
answers156
viewsHow to inherit a VBA form?
I need to inherit a form in a VBA to use it as a basis for other forms. For example, a form called "Table" contains a list of two columns and buttons for 'Edit', 'Include' and 'Rule out' the items;…
-
2
votes2
answers707
viewsWhy use Legacy Interface instead?
I would like to know why in java one should usually prioritize the use of interfaces, rather than inheritance with classes.
-
2
votes1
answer159
viewsLegacy PHP and Doctrine: Duplicate Definition of column
Good afternoon. The following error is happening: Error: Duplicate Definition of column 'numg_usuario' on Entity 'Usuario' in a field or discriminator column Mapping. My User class extends from…
-
2
votes1
answer74
viewsInstantiating a class "x" from another class "y" inherited by the class "x"
If I have a class Diretor who inherits from the class Funcionario, so I say a direct is also an employee. Public class Diretor : Funcionario{} Diretor diretor = new Diretor(); But I’m allowed to…
-
2
votes1
answer114
viewsOrganizing forms inheritance - C#
I’m doing a program for selling products and I have a design problem. The differential of this program is that it can take on two different faces: one for the sale of chocolates and the other for…
-
2
votes1
answer93
viewsIs the implementation of an interface part of the encapsulation or heritage pillar?
The implementation of an interface is part of the pillar of encapsulation or heritage of the POO? As far as I know encapsulation disrespects the visibility of the attributes and methods contained in…
-
2
votes2
answers697
viewsClasscastexception error when trying to cast between classes
I have the problem to perform a "Cast" in a class, when using the inherited class method of the following error: "entity. Aula cannot be cast to tableview.Aulatv" Here gives the exception described…
-
2
votes1
answer3545
viewsDestroy React Component (Unmounting Component)
I would like to know how to destroy a component with React by clicking a button. I found a way out, but in my conception it is quite "gambiarrosa". I have a state called show and when click on close…
-
2
votes3
answers121
viewsInteresting question about inheritance and polymorphism
I found this question of an open competition interesting: Class A public class ClasseA { public int metodoX(){ return 10 } public int metodoX(int n){ return metodoX() + n } } Class B public class…
-
2
votes1
answer70
viewsDoubt about which Inheritance to use in the Entity Framework
I only had the opportunity to use the EF basically 1x. Therefore, I am with many doubts, even consulting a lot google. I have a client application that will take various data from the logged user’s…
-
2
votes1
answer249
viewsHow to count the number of all instances of a class and their respective subclasses?
I have a class A, where A extends into B and in C. I have a counter of instances in A. public Class A { ... private int nInstancias = 0; ... public A(){ nInstancias+=1; ... } ... public int…
-
2
votes1
answer608
viewsWhat does the class name mean in super(). __init__()?
How the name of the classes inserted within the constructor’s parentheses works __init__( ), in the classes Telefones, TiposTelefone and Agenda? This is only an excerpt of Chapter 10 code from the…
-
2
votes1
answer257
viewsProblems with multiple inheritance and interface use
I am creating a simple bank system (studying), there is a Account class with basic registration information, and a System class that manages all accounts. I intend to create a class ContaDiretor…
-
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
votes1
answer120
viewsHeritage is slowing the startup of my SPRING BOOT application
I’m working on an automatic text messaging system, in my class hierarchy I have an abstract class at the top called TaskNFSBusiness which sets the rules for messages that are not in real time, it is…
-
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…
-
2
votes1
answer67
viewsInstantiate a class with private attributes
How can I take the attributes of the person class and instantiate them in the medical class and then display it? The doctor and the patient are people and both have class attributes Pessoa. I left…
-
1
votes1
answer53
viewsJava Socket Specification and Implementation
I created a class MySocket that extends java.net.Socket, but I saw that class java.net.Socket implements the interface java.io.Closeable, and my question is: In my class MySocket I am obliged to…
-
1
votes2
answers335
viewsInheritance and manipulation of a superclass’s methods
Inheritance is said to inherit all the methods of a super class. But in doing class Soma{ private double total; public void setSoma(double s1, double s2) { total = s1+s2; } public double getSoma() {…
-
1
votes0
answers216
viewsHow to use inheritance in Managedbeans?
Considering: public abstract class Usuario { public Usuario(String login, String senha) { this.login = login; this.senha = senha; } private String login; private String senha; } public class…
-
1
votes2
answers334
viewsCSS heritage in Divs
I’m having trouble editing some legacy Ivs. Let’s take a look at the example: This is the current code: <div id="conteudo"> <div class="titulo">xxx</div> <div…
-
1
votes2
answers1520
viewsHow to model with inheritance a structure of People?
Hi, I’m having a hard time doing my Pessoa modeling. Theoretically it seems a very simple thing, but I can’t find a way to follow, say, "good programming practices". My problem is this: In my system…
-
1
votes1
answer179
viewsHow does class inheritance work in C#?
I have class 1 and class 2, class 2 inherits from class 1. Other classes that inherit from class 2 will inherit the attributes of class 1?
-
1
votes4
answers708
viewsConversion of interface list into object list: (List<Interface> in List<Object>)
I need to convert a IList<Interface> in a List<Objeto>. Take the example: public interface IObjetosBase { IList<IObjetosBase> get(); } public class ObjetosBase : IObjetosBase {…
-
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
answer103
viewsMethod override of an interface
I’m having a question about the method override of an interface. I can override a method in a daughter class that inherits from the mother class the implementation of an interface and in that method…