5,347 questions
-2
votes
0
answers
37
views
Can i give a value to a variable inside of an abstract class? [closed]
i know that we can not write code or return something inside a method in abstract class (well becuse its abstracted!)
what about variables inside of abstract class ? can i for example define a 'x' ...
4
votes
2
answers
130
views
How to override inject() dependency from abstract base class in Angular?
I have an abstract base class that used to accept a service via constructor injection:
export abstract class BaseEditEventClass<T> extends BaseFormClass {
constructor(protected _service: ...
0
votes
1
answer
89
views
How to manage multiple JPA base entities (UUID, Long ID, Soft Delete) without redundant classes?
This question is likely already asked, but I am not satisfied with the answers. I add the link for reference.
Previous Question
Now, coming to the point, I have six different abstract classes which ...
3
votes
1
answer
740
views
Difficulty setting up threaded BST in C++
I'm having trouble implementing a threaded Binary Search Tree in C++. I have a non-threaded tree completely implemented (see below code). What I'm having difficulty with is setting the threads to ...
1
vote
0
answers
104
views
Exclude methods consisting of a single pass statement from coverage reports in python
In my class, I have some methods that can be overridden by subclasses, but do not need to be.
I like to test my project and generate a coverage report using coverage.py.
Because the method of the ...
3
votes
5
answers
219
views
Creating a list of types that derive from abstract class
I have classes ProgramA and ProgramB that derive from abstract class Program.
I sum them up into an array std::vector<Program*> and I pick a random one from there that runs for awhile.
#include &...
1
vote
4
answers
158
views
Polymorphism and abstract classes in Java
Let's say I have the following classes:
public abstract class Animal {
public abstract void talk();
}
class Dog extends Animal {
@Override
public void talk() {
System.out.println(&...
1
vote
1
answer
44
views
How to bind to different abstract class implementations with additional properties without binding failure in WPF
I implemented the classes UtilityElectricityConsumptionModel and UtilityNaturalGasConsumptionModel from the abstract class UtilityConsumptionModel. The UtilityNaturalGasConsumptionModel just has the ...
-1
votes
2
answers
113
views
Is possibility to derive from multiple interfaces the only difference between abstract class and interface?
In the past life was easy, interfaces could not have implementations, abstract classes could. Nowadays (like for 5+ years already lol), the only difference between abstract class and interface in C# ...
0
votes
1
answer
61
views
Implementing abstract classes
I am a beginner in Python coding and I try to learn abstract classes. I have a problem with implementing two exams which extend abstract class Exam, defining contract for diagnostic test.
class Person:...
0
votes
1
answer
84
views
using typed template argument with default value as abstract class in c++
Using c++20, I have the following idea to generalize access to multiple chips in a circuit:
An interface should allow reading/writing to all chips with different address bits and register sizes (8, 16,...
1
vote
1
answer
63
views
Junit test cases for a method in Abstract Class which calls a method of its non-abstract Super class
I have a Parent Class Parent
class Parent{
public String calculate(String input){
// does lots of external system calls and complex calculations
}
}
Then I have an ...
-1
votes
1
answer
75
views
Calling Super function from child function
I have the following structure:
class grandparent(ABC):
@abstractmethod
def get_obj(self):
pass
class ParentBase(grandparent):
def __init__(self, obj1):
self.obj1 = obj1
...
0
votes
0
answers
311
views
Force subclass to implement a class property in Python
I want to force all subclasses of a class to implement a property. As I understand it, I have to use abc methods for this use case. I tried the following:
from abc import ABC, abstractmethod
class ...
0
votes
1
answer
85
views
C# routine to create derived classes from an abstract class
I am trying to develop a routine that will run an sql statement and use the results to populate class objects that are derived from an abstract class, something like the following:
public static List&...
-5
votes
2
answers
118
views
How to use abstract class as variable type in C# [duplicate]
I'm trying to use an abstract class as variable type in C# and getting System.StackOverflowException: 'Exception_WasThrown' error when try to read ResultData.ValuesDescription
public abstract class ...
1
vote
3
answers
153
views
Abstract Method override in Python
If I create an abstract class in python using abc with an abstractmethod as follows and create a concrete class which doesn't use def to override the abstractmethod but instead attempt to set the ...
2
votes
2
answers
69
views
Abstract Base Class property setter absence not preventing Class instantiation
I'm trying to get abstract properties to work, enforcing property getter & setter definitions in downstream classes.
from abc import ABC, abstractmethod
class BaseABC(ABC):
@property
@...
0
votes
0
answers
18
views
Mark a method as "requires override" in Swift? [duplicate]
I want to have something like
class Parent {
@mustBeOverridden
func overrideThis(_ s: Source) -> Target {
// does not do anything, i.e. it is "abstract"
}
}
class Child1: ...
0
votes
2
answers
149
views
Templated constructor of abstract class without parameter type deduction in C++
I want my abstract base class to have a templated constructor, but can't get it to work without an extra parameter to deduct the type from.
I want to do something like this:
class Base {
public:
...
0
votes
1
answer
56
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 ...
0
votes
1
answer
124
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 ...
0
votes
1
answer
90
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
4
answers
134
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
1
answer
50
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 $...