Questions tagged [inheritance]
Inheritance is the system in object oriented programming that allows objects to support operations defined by anterior types without having to provide their own definition. It is the major vector for polymorphism in object-oriented programming.
inheritance
42,701
questions
0
votes
1
answer
37
views
inherit constructor and factory in flutter
I'm learning flutter and I'm trying to turn requests results into more convenient objects, so I created the basic schema of a response (which is not supposed to be instantiated anytime) :
class ...
0
votes
0
answers
27
views
Assigning my custom class to an object/widget from a .ui file [duplicate]
Writing my 1st code in python, how can I create an instance of a class of my own and assign it to an object/widget from a .ui file?
Something like this:
import sys
from PyQt6.uic import loadUi
from ...
-1
votes
1
answer
26
views
Why does the custom ArrayAdapter constructor in this example not match the superclass constructor exactly?
I was following a tutorial on creating a custom ArrayAdapter for a ListView in Android. Here is the custom adapter class from the tutorial:
public class NumbersViewAdapter extends ArrayAdapter<...
0
votes
0
answers
36
views
THREE.js Object is not visible when inheriting from other class
I am fairly new to THREE.js and Angular.. well, let's just say JavaScript and TypeScript in general, so my question might be a rookie one. I apologize in advance.
I have been building a project in ...
0
votes
1
answer
57
views
Provide implementation for an abstract method from an interface
Is it possible to override a method implementation by deriving from an interface which gives a default implementation for that method? If not, how should I restructure my code to avoid explicit method ...
-1
votes
1
answer
39
views
Java Protected Field Access Issue in Subclass
What is the difference between public, protected, package-private and private in Java?
The question's answer cannot answer my question. It's not a duplicate question. I totally know the diagram of ...
0
votes
2
answers
45
views
How to upgrade Java class to extension class?
I have a simple problem. I have a large class:
public class Base {
public Field1Data field1;
public Field2Data field2;
public Field3Data field3;
// many more fields later...
public ...
0
votes
1
answer
34
views
Overriding implementation of a library Component
The problem (Angular 14)
I want to override a function from a library Component (Angular Material) without re-implementing the whole component.
The idea
My thinking is inspired by one of the examples ...
0
votes
2
answers
60
views
multiple inheritance without defining a class [duplicate]
I'm not sure that's possible, and I'm wondering if that's the way to go, or if there exists a better way of doing that.
I'll create a toy example to expose what I'm looking for.
Suppose I have people ...
1
vote
1
answer
84
views
Inherited functions returning self reference with derived type
I am trying to create a system where one base class has a bunch of functions, then derived classes can inherit it and add more functions. However, all of these functions return the this keyword and I ...
-1
votes
0
answers
56
views
Compiler misidentifying/unrecognising type [duplicate]
I have the following class with constructor:
command.h:
#include "./robots.h"
enum class CMD { //...... };
class CommandTemplate {
//.....
public:
virtual std::unique_ptr<...
1
vote
3
answers
80
views
Inheriting Structs in C++
I am working with the LibAV library, converting it from C to C++ (and moving to an object oriented style).
This library has structs to hold data, which need to be created using specific allocation ...
0
votes
0
answers
56
views
C++ continue base class bitfield in derived class
I have a base class with a bitfield
enum Enum {
ENUM1,
ENUM2,
...
ENUM8
};
struct Base {
Enum type : 3;
};
I am inheriting a class
struct Derived : public Base {
bool bf1 : 1;
u32 bf2 : 19,...
1
vote
2
answers
78
views
How to declare a function parameter to accept all derived types of a generic abstract type?
these are base type
[DataContract]
public abstract class InputModelBase<T>where T : InputModelParametersBase
{
[DataMember]
public string Token { get; set; }
[DataMember]
public ...
2
votes
1
answer
46
views
How does __slots__ inheritance work? (My code works and I don't know why)
Here is the example of my implementation:
class FileHandler:
__slots__ = ("_target_path",)
def __init__(self, target_path: Path) -> None:
self._target_path = target_path
...