All Questions
Tagged with overriding abstract-class
143 questions
1
vote
0
answers
152
views
Difference between `public` and `private` inheritance when inheriting from abstract classes
I have a class Placeable:
struct Placeable {
virtual void place_at(int x, int y) const {}
virtual ~Placeable() = default;
};
I also have several other types, such as Box, that inherit from ...
0
votes
1
answer
281
views
Kotlin: how to have abstract values as default arguments for abstract functions?
I have a sealed class that represents my screen states, and the different screen states are data classes, since I want to be able to copy them while changing just one value.
Unfortunately Kotlin doesn'...
0
votes
0
answers
17
views
Typescript: chains of abstract classes with overrides [duplicate]
I have a root abstract object:
export abstract class GameBase {
// takes a string and executes the given move
public abstract move(move: string): GameBase;
// a bunch of other helpful stuff, ...
0
votes
0
answers
95
views
How to invoke the method in abstract class that has been overriden in the subclass in java?
In this below code:
interface I1 {
void m1();
}
interface I2 {
void m2();
}
abstract class A implements I1, I2 {
public void m1() {
System.out.println("Inside A: m1()");...
2
votes
2
answers
3k
views
How to define keyword/variadic arguments in a NotImplementedYet ABC method (avoiding pylint: arguments-differ)
I have an Abstract Base Class in python that looks like this:
from abc import abstractmethod
class Task:
@abstractmethod
def run(self, **kwargs):
raise NotImplementedError()
This is ...
1
vote
1
answer
537
views
Overridden method in derived class
I have an abstract class with an abstract method and this class is inherited by over 100 other classes where we override this virtual method.
Now there is a slight change in business requirement and ...
0
votes
0
answers
533
views
Implement abstract function from parent class with typed arguments in PHP
I am trying to create a base class which will contain functions that all child classes must implement, but the type of the arguments will depend on the child class.
When I try the following, I get the ...
12
votes
2
answers
728
views
Overriding method shadows overloaded final version
I have the following code:
struct Abs {
virtual void f(int x) = 0;
virtual void f(double x) final { std::cout << 2; }
};
struct Sub: public Abs {
void f(int x) final { std::cout <...
1
vote
1
answer
169
views
There was an error reflecting property Member when using the new keyword on an abstract class virtual property
I would like to use an abstract base class (call it AbstractBaseClassA) which holds only one property (virtual - Property1) of type List of another abstract base class (Call it AbstractBaseClassB).
I ...
4
votes
3
answers
7k
views
Implementing an interface with additional parameters in a method
I have a class MyClass that implements the interface IResp.
public interface IResp {
Response onResp(String a, String b)
throws Throwable;
}
public class MyClass implements IResp {
...
-1
votes
3
answers
445
views
Java Overridden method visibility scope
How is the following program correct?
abstract class Calculate
{
abstract int multiply(int a, int b);
}
public class Main
{
public static void main(String[] args)
{
...
0
votes
3
answers
70
views
Is it possible to use a method from one parent class to implement an abstract method from another parent class?
I've got the following classes:
class ServoPart {
private:
bool move() {
/* move implementation for a singular servo */
}
}
struct RoboPart {
virtual void doJob() =0;
virtual ...
4
votes
2
answers
777
views
Is it possible to override the nested class definition of an abstract parent, within an inheriting class?
Context
I have an scenario in which I wish to define several Bar classes, each of which must define Request, Response and Error classes of their own. For this reason, I have written an abstract Foo ...
0
votes
1
answer
205
views
How to polymorphic call a method from a stack of two different child types
I have 4 separate classes UI, Parent, child1 and child2.
I have a parent stack containing both child1 and child2.
I'm trying to call a method when iterating through the stack that changes depending on ...
1
vote
0
answers
171
views
Overloading operators (like +,-,*,/) in abstract classes in C#
I am trying to implement the class Vector as an abstract one and have stuff like Vector2D and vector3D inherit from it. However, I ran into a problem with the overriding of operators, because they ...