Questions tagged [abstract-class]
Abstract classes are classes which cannot be instantiated. They exist to provide common functionality and interface specifications to several concrete classes.
abstract-class
5,332
questions
0
votes
1
answer
43
views
Type-hinting a dynamically generated concrete subtype of an abstract class in Python
I have an abstract class, Float, that generates concrete subclasses dynamically. I would like to type-hint the return type so that the IDE knows that it's a concrete subtype of Float. That is, when ...
-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
0
answers
23
views
pybind11 binding of a function with virtual class as argument or return type
here is an example of a code where i have a virtual class A, with its child A_2 and other classes/functions that have A as argument/return type. In use i could use instead A_2, A_3 ...
#include <...
0
votes
1
answer
70
views
C++ Best Practices: Serialization and Abstract Classes without library access
Preface: Serialization libraries cannot be used due to restrictions in the development environment, and the latest version usable is C++ 11.
I have various struct that need to be serialized and ...
1
vote
0
answers
18
views
Issue with Conditional Mapping in Abstract and Derived Classes Leading to EF6 SaveChanges Error
The OfType part of the query doesn't work as expected, and there’s an error when saving changes in the database.
Code:
using System;
using System.Data.Entity;
using System.Data.Entity....
0
votes
0
answers
36
views
Guice getInstance to inject child classes
I have an abstract class and its 2 implementations and trying to avoid injecting the individual classes in the Factory. I would prefer using Guice's Injector.getInstance method instead. But Guice ...
0
votes
1
answer
34
views
Serializing and Deserializing abstract classes in YAML
Let's say we have a game, characters in which have special abilities. All abilities share an abstract base type called AbstractAbility. Each character has a list of said base type (List), elements of ...
0
votes
0
answers
32
views
Implementing Generics/Abstracts/Interfaces with serialization
I have a couple of classes that need to be serializable using DataContractSerializer, however I am trying to create a generic Class called XMLDocument, that allows for a WeatherData, RSSDocument, and ...
0
votes
0
answers
23
views
using lombok @Delegate with abstract classes
I want to create a delegate around a class for hot swapping.
I tried this:
@AllArgsConstructor
@Setter
public class DelegateClock extends Clock {
@Delegate
private Clock clock;
}
Unfortunately, ...
0
votes
3
answers
65
views
C++ with Qt5 : lock a common mutex before calling the actual override implementation of a method
I have an abstract class like this :
class Thing
{
public:
Thing();
virtual ~Thing();
static QMutex s_mutex;
virtual void load() = 0;
virtual void translate() = 0;
virtual ...
0
votes
0
answers
66
views
Optimal validation of an object in C++ if it receives raw data
I receive data entered by the user and I need to initialize a class with it that has an abstract parent class. I can do the check before initializing the class, but in this way the class validation ...
0
votes
1
answer
38
views
Abstract __construct with variable argument count
I have a quite a few DTOs like so:
class AccountDTO extends AbstractNestedDTO {
public function __construct(
FirstNameDTO $firstName,
LastNameDTO $lastName,
BirthdayDTO $...
-1
votes
2
answers
66
views
How to apply generics correctly to PHP?
Background
I do have classes (here: ClassA and ClassB) that shall be tested. As these classes are similar, I created an abstract test-class that implements an interface.
Problem
At level 7, PhpStan is ...
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 ...