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.

inheritance
0 votes
1 answer
41 views

Antlr grammars that generate actual class inheritance

Need to know, is it possible to generate parsers, lexers, listeners, etc, by importing subset-grammars? I see that the supergrammar subgrammar pattern is possible, but I'm not sure I see a true class ...
Michael W. Powell's user avatar
-2 votes
1 answer
58 views

Cast a List<derivedType> into a List<baseType> without breaking the reference

I have multiple lists of type ArmorBase and WeaponBase that inherit the ItemBase class. I also have a List that represents the current selected item List public List<ItemBase> ...
Bruno Pasini Fiorini's user avatar
-4 votes
2 answers
55 views

I don't want to call the parent constructor. Can we do something about this? [closed]

I am trying to explore JS classes and I am getting error if I am not calling super(). ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived ...
Tazeen Khan's user avatar
1 vote
3 answers
75 views

If I already have an instance of a super class, how can I create an instance of a child class from it?

How do I properly inherit data from an instantiation of a super class? For example, consider something I can get to work, but is confusing in its behaviour: from dataclasses import dataclass from ...
bzm3r's user avatar
  • 3,770
0 votes
0 answers
16 views

Efficient design solution for handling dynamic marking schemes with multiple levels and subjects

We're developing a grading system for a school with multiple levels (e.g., elementary, middle school, high school) and various subjects within each level (n subjects < 200). The challenge is that: ...
shithanshu mishra's user avatar
0 votes
1 answer
65 views

Calling student method from parent class definition

I'm making an LCD menu and having trouble with the lcdmenu (main menu) and submenu interaction. class submenu; class lcdmenu { protected: command **commandlist; submenu **submenulist; ... ...
Andy Votava's user avatar
-1 votes
1 answer
66 views

Hide fields in child class when inheriting

Is it really impossible to hide these two fields in the inspector of the child class when inheriting, without using a custom inspector? If yes, then what is the best way to change the value of ...
Ilya's user avatar
  • 374
0 votes
2 answers
41 views

Pydantic Inheritance Defaults

How can I typehint a parent BaseModel such that a child subclass can provide defaults for some of the fields: from pydantic import BaseModel class Parent(BaseModel): first: str second: str ...
Oliver's user avatar
  • 335
1 vote
1 answer
50 views

PHP inheritance with inherited properties

I'd like to have the following class configuration. class Parent { protected ParentMapperInterface $mapper; public function __construct(ParentMapperInterface $mapper) { $this->...
Dima Dz's user avatar
  • 524
2 votes
1 answer
34 views

Python Django access fields from inherited model

Hi I have a question related to model inheritance and accessing the fields in a Django template. My Model: class Security(models.Model): name = models.CharField(max_length=100, blank=False) class ...
Dennis's user avatar
  • 99
0 votes
1 answer
76 views

Abstract function's copy constructor deleted, class inherited from this class gives error

Given header files named Point.h: #pragma once struct Point { double x, y; }; and Shape.h: #pragma once #include "Point.h" #include <vector> class Shape { public: ...
Chris Lee's user avatar
0 votes
1 answer
74 views

Strange inheritance behavior with base class

I hope someone can help me since can't quite understand how it is possible that the following code can work. I have a base class with some classes that derive from it. Each derived class has its own ...
lightimpact90's user avatar
1 vote
1 answer
49 views

Constructor parameter is null until parent is not initialized

Look at the following code: abstract class A { init { f() } abstract fun f() } class B(val p: () -> Unit) : A() { override fun f() { try { p() ...
Alexey's user avatar
  • 3,182
0 votes
1 answer
44 views

Sharing SQLAlchemy models between flask and non-flask python projects

We have 2 projects - Project_A and Project_B. Project_A does data processing, saves processing results to a database, generates an .sql dump and uploads it to cloud storage. Project_B is a flask app, ...
y z y s z n's user avatar
0 votes
2 answers
60 views

Initializing properties of derived classes in Kotlin

I want to know why exactly my code returns "nullnullnull" instead of expected answer and why does it work correctly when method is used. Consider the following code: open class Base( ...
entendrious's user avatar

15 30 50 per page