All Questions
Tagged with inheritance abstract-class
1,050
questions
-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
84
views
C# 11 - Static abstract members in interfaces through abstract classes?
C# 11 introduced static abstract members in interfaces.
But from what I'm experimenting, it only force the direct child to implement these static abstract members. That static abstract modifier can't ...
-1
votes
1
answer
59
views
Dotnet class method with generic return type and one generic argument [duplicate]
I try to make a class method when return type is generic and also one of the arguments is generic.
The Return type should be generic class Result, which looks like this:
public class Result<T>
{
...
2
votes
1
answer
128
views
Abstract @property - instantiating a "partially implemented" class?
I read this very nice documentation on abstract class abc.ABC. It has this example (shortened by me for the purpose of this question):
import abc
class Base(abc.ABC):
@property
@abc....
0
votes
1
answer
73
views
Is there a way to define local static variables for all implementors of an interface in Java?
I have several classes, about 40 or so, that implement a single interface. I'd like to introduce a static variable that is local to each implementing class of this interface. For example:
public ...
0
votes
0
answers
10
views
Typescript abstract child inheritance typing problematic
How could I have "this.foo" as "Foo" in "Bar" class ?
abstract class AFoo {}
abstract class ABar {
constructor(protected foo: AFoo) {}
}
class Foo extends AFoo {
...
0
votes
1
answer
54
views
How should I define a superclass that guarantees a property that is readable but not writable?
I want to define a data structure that can be used as an input for various methods that access the data in a read-only fashion, but in various contexts this data should either be completely mutable, ...
0
votes
1
answer
30
views
EditorFor for derived classes when passing it packed as Abstract class
I have many classes that inherit from an abstract class.
I'm trying to make @Html.EditorFor to choose correct editor when we pass an class packed up in abstract class which is inherited from to it.
...
0
votes
0
answers
40
views
How to retrieve an inherited member function to override an interface definition - C++
I'm trying to build a mini ORM in C++, and while attempting to implement SELECT, I thought that inheritance would be a good option to always be guided towards which function to use.
However, I'm ...
0
votes
1
answer
53
views
Allow a subclass's function to specify a sub-type without breaking Liskov substitution
I have an abstract base class, and I want its subclasses to specify an input type among a set of input types. For example, if I have another ABC TaxForm that W2TaxForm is a subclass of:
class ...
1
vote
2
answers
98
views
How to inherit from C# generic abstract class in F#
I have an abstract generic class in C#
public abstract class PaymentSystemBase<
TPayInSettings,
TPayOutSettings,
TRefundSettings,
TCashierContract,
TPayoutContract
> : ...
1
vote
0
answers
32
views
Why I can't assign a variable of class to an abstract class type in TypeScript?
I have the following code and it works correctly:
type Class<T> = new (...args: unknown[]) => T;
abstract class AbstractClass<T = unknown> {
constructor(protected element: T) {}
...
-1
votes
2
answers
50
views
Java: Statically check that two pair of classes implement a certain function [closed]
Let's say I have two abstract classes A1 and A2. Is there a way to ensure that every combination of (C1 extends A1, C2 extends A2) has a certain operation() defined? I want to make sure the code does ...
0
votes
1
answer
178
views
add dynamic class for inheritance and mapping for class name
I'm working on a Python project where I have two different Object-Document Mappers (ODMs), Beanie and Bunnet, for managing data in a database. Each ODM requires a different class structure for ...