Skip to main content

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.

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 ...
eli's user avatar
  • 29
-1 votes
1 answer
28 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<...
minh's user avatar
  • 27
0 votes
1 answer
58 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 ...
Elia Giaccardi's user avatar
-1 votes
1 answer
41 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 ...
maplemaple's user avatar
  • 1,435
0 votes
2 answers
48 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 ...
tuskiomi's user avatar
  • 183
0 votes
1 answer
41 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 ...
Sulejman's user avatar
0 votes
2 answers
62 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 ...
Elerium115's user avatar
1 vote
1 answer
87 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 ...
CreeperCrafter979's user avatar
-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<...
steve89's user avatar
1 vote
3 answers
81 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 ...
ThomasNotTom's user avatar
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,...
Evgeny Ilyin's user avatar
2 votes
2 answers
88 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 ...
FDB's user avatar
  • 1,055
2 votes
1 answer
48 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 ...
Todor Naydenov's user avatar
0 votes
0 answers
24 views

Automapper mapping to derived type based on predicate when base class is not abstract

I need to map a model to a derived class based on a condition, but otherwise map to another class. for example if I have these classes class Shape { } class Rectangle : BasePolygon { } class Square :...
Moniker's user avatar
  • 135
0 votes
1 answer
46 views

DRY - Derived class with static methods

In Unity C#, I have a base class Baker, it's derived from ScriptableObject, and I'm deriving from it CakeBaker, BreadBaker, PieBaker. ScriptableObjects can only be created statically, using ...
TheUmpteenth's user avatar

15 30 50 per page