Questions tagged [inheritance]
Inheritance is the system in object oriented programming that allows objects to support operations defined by anterior types without having to provide their own definition. It is the major vector for polymorphism in object-oriented programming.
inheritance
42,719
questions
-1
votes
0
answers
31
views
Error inheriting non pure virtual function from class that implement another class
In my code i have this three classes, i'm using the visual studio compiler and it's compiling without any error and runs fine.
But i don't need the methodes width and height in my interface IBrick, if ...
-2
votes
0
answers
55
views
Is there a way to make my compiler warn if my method-call explicitly calls up to a non-direct-parent superclass? [duplicate]
Background: After some careless refactoring, the following dumb mistake crept into my codebase, resulting in a somewhat-hard-to-track-down runtime misbehavior:
class Grandparent
{
public:
void Foo(...
1
vote
1
answer
72
views
How to provide a 'blanket implementation' of a static method for the derived class?
Consider this:
struct Base {
static Base make() { return {}; }
};
struct Derived : public Base {
// I _would_ want to have a `static Derived make()` automagically here
};
One approach to the ...
0
votes
0
answers
24
views
Lua: Assistance Needed in Using Inheritance in conjunction with case-insensitive metatables/metamethods? Doable?
I've been trying to wrap my head around utilizing inheritance with Lua (https://www.lua.org/pil/16.2.html and Case insensitive array in Lua as references) but also integrating a case-insensitive ...
0
votes
1
answer
33
views
Composable inheritance... how to add padding to inherited content?
I want to do some kind of Composable Inheritance. I need a parent composable with a Scaffold, and the children must have the inner content to the scaffold. How can I apply the innerPadding to the ...
0
votes
3
answers
91
views
Inheritance of C# functions and using reusability
I'm drawing a complete blank on what to actually call what I want to do (hence the difficulty I am having in trying to research it). But what I do have is this:
public interface IShapes
{
public ...
2
votes
1
answer
85
views
How to return smart pointers and covariance in C++
I am following this tutorial to understand how to return smart pointers and covariance in C++.
#include <memory>
#include <iostream>
class cloneable
{
public:
virtual ~...
-1
votes
0
answers
20
views
Need to extract a method to use in equals implementation with Hibernate DTO's
I am updating a Java project and had to add an equals() implementation 3 java DTO files (call them Child1, Child2 and Child3) which all extend the DTO Parent class. IntelliJ generated the following ...
4
votes
1
answer
94
views
Assign base object without changing inherited ones?
How valid is it to assign a new object to a base one, without changing the inherited ones?
The example below works as expected, but is it by chance?
This example is simple, but is there any situation ...
-2
votes
1
answer
54
views
When calling an inherited method from a derived class it tries to use the uninitialised fields of the base class [closed]
I have two classes. One called Agent, and the other called Player. Agent is the base class and Player is the derived class.
When calling the function SetHand() from the derived Player class, I run ...
0
votes
0
answers
14
views
Declaring an interface property as a derived type [duplicate]
Currently I have a series of services/repos that are allowing a generic of a custom type. I want to add a generic list to that interface such that when a class inherits the interface it can apply a ...
-1
votes
0
answers
34
views
invalid covariant return type for [duplicate]
Consider the following example, which is some part of the bigger codebase, in the getInstance() if I dont return a pointer to the derived class, i.e., just void or int or a different type, the ...
-1
votes
0
answers
32
views
Does a socket instantiated in a parent class belong to its child class?
I'm making a messaging service in java where I'm using sockets and object input/output streams. I wanted to make this as object oriented as I can (to learn OOP) so for the client side I'm making an ...
0
votes
1
answer
54
views
What are the differences between using mutiple or'ed typehints vs abc and an inheritance hierachy in Python?
Python is a dynamic language. This means that types are dynamic at runtime and Python makes use of the concept of Ducktyping.
What this means is that for any object x was can do
x.some_function()
x....
1
vote
1
answer
42
views
Inherit override-equivalent as different methods
Several methods from interface, super class or new method are override equivalent. I need to make different realization for each. Example:
public interface A {
int f();
}
public interface B {
...