42,900 questions
0 votes
0 answers
54 views
Casting collection<implementation> to collection<interface> [duplicate]
In Java, having two interfaces: public interface SomeAbstractResult {} public interface SomeInterface { Collection<SomeAbstractResult> someMethod(); SomeAbstractResult someMethod2(); } ...
0 votes
1 answer
83 views
Constructor not accepting list of derived class as argument [duplicate]
I have tried using both base class and interface and in both instances I am told a constructor that takes my arguments does not exist. I have two classes that are related to each other and I want to ...
-3 votes
0 answers
27 views
Why is explicit Parent.__init__(self) discouraged in Python Multiple Inheritance compared to super()? [duplicate]
Body: I am learning Multiple Inheritance in Python. In my code, I am initializing the parent classes by calling them explicitly by name, like this: I read that I should use super(), but when I use ...
Best practices
0 votes
6 replies
165 views
dynamic_cast to any one of several options
Somewhat similar to this question, I have something like this: class DerivedA: public Base { void operation(const Base& x, const Base& y) override // pure virtual in Base { ...
0 votes
0 answers
49 views
Mapstruct and multiple derived classes
I am having trouble wrapping my head around subclass mappings. I have 3 classes: @Data public class Parent { long id; String name; public boolean isEmpty() { return StringUtils.isEmpty(name)...
Advice
0 votes
9 replies
127 views
Why the inherited method output parent's data?
Explain please why the output is "Base" ? Isn't getClassName method inherited? class Base { public String className = "Base"; public String getClassName() { ...
3 votes
1 answer
196 views
“The type initializer threw an exception” even though static fields are initialized [duplicate]
I'm getting a TypeInitializationException when running this C# code. It happens when a constructor tries to add an instance to a static list that should already be initialized. You can run it here: ...
0 votes
1 answer
128 views
C# .NET extension without extension method [closed]
I have a base class and multiple derived classes: public class Camera { } public class CameraManufacturerA : Camera { } public class CameraManufacturerB : Camera { } public class ...
Best practices
1 vote
6 replies
225 views
Base class and derived classes in Qt
I'm building a Qt wrapper for RtMidi. As starting point I created two separate classes QMidiOut and QMidiIn that wrap RtMidiOut and RtMidiIn. I don't want to duplicate code for the common methods (e.g....
-3 votes
0 answers
63 views
On calling inherited method from parent class by object of child class why instance variable of parent class is printed [duplicate]
class parent{ private String x = "Parent"; public void printmsg() { System.out.println("value is "+ this.x); } } public class child extends parent{ ...
2 votes
0 answers
64 views
SWIG multiple inheritance problem when returning a C++ class wrapped as an interface
I'm trying to wrap a C++ class using SWIG that involves multiple inheritance and another class with a method returning a shared pointer to a class declared as an interface in SWIG. Here is a ...
1 vote
1 answer
79 views
Problem with manim rendering of the arrows
I want to use manim to render a spiral, which is crucial for later animation. Even the output says that the first arrow's module is greater than the second arrow, the render result says that the first ...
1 vote
3 answers
94 views
Inheritance of decorated classes
I'm using Python decorators to implement common functionality across multiple classes. The problem comes when I want the decorated classes to inherit from each other: super() doesn't seem to delegate ...
2 votes
0 answers
121 views
Hibernate 6 native query on parent class fails with “ORA-17006: Invalid column name”
After upgrading from Hibernate 5 to Hibernate 6, a native query that used to work now fails with an “ORA-17006: Invalid column name” error. Entity definitions Base class: @Entity @Table(name = "...
2 votes
2 answers
196 views
derived class cannot call recursively inherited member functions C++
I'm making it using multi inheritance with a pair struct that contains an index and the type of the element in a recursive structure like this: template<int index, typename... ts> struct ok; ...