All Questions
Tagged with inheritance class
4,057
questions
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 ...
-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 ...
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;
... ...
1
vote
2
answers
65
views
Is it possible to override a Point2D object from a superclass to a Point2D.Float?
I have defined a class called Entity with a Point2D object in it called pos. The class is a superclass and it's not specified if pos should be a Point2D.Float or a Point2D.Double, that's left for the ...
-3
votes
1
answer
71
views
Hit a snag whilst adding a subclass to std::vector
My idea was initially to create my own custom vector with methods built in for various mathematical calculations, as well as the usual std::vector features, for the sake of regression analysis. I ...
4
votes
2
answers
109
views
Passing parameters to parent constructor using Perl's new class syntax
This question concerns Perl's class syntax (new as of Perl 5.38.0). I have two classes, Rectangle and Square, with Square inheriting from Rectangle. They have different constructor arguments; ...
1
vote
1
answer
40
views
If Python builtins derive from ABCs, then why is their metaclass type instead of ABCMeta?
I was reading PEP-3119, and I discovered that builtins derive from ABCs.
From PEP-3119:
The built-in type set derives from MutableSet. The built-in type frozenset derives from Set and Hashable.
In ...
-1
votes
1
answer
41
views
How to set up classes for parsing custom data types in C#
I'm working on a saving/loading system, and I'm trying to serialize and deserialize various objects. I'm working in Unity, and I've created one custom class for the game objects and their behaviours, ...
0
votes
1
answer
79
views
Why is there no error if a class defines a member with the same name and type as the class it inherits? Which of the two members is used? [duplicate]
I am currently learning programming in university and I was messing around and wrote this code and I got curious:
class Student{
public:
string name;
string address;
};
class Instructor: ...
0
votes
1
answer
79
views
Use defined operators from base class in inherited class
Assume I have a base class
class Vector
{
public:
Vector(const std::vector<float> &elements);
static Vector add(const Vector &v1, const Vector &v2);
Vector Vector::...
2
votes
1
answer
46
views
Auto inherite a parent class with decorator
I have a class decorator p() that can be used only on classes that inherite from some abstract class P.
So anytime someone uses p it should be written as follows:
@p()
class Child(P):
...
Is ...
1
vote
0
answers
45
views
Python3 custom pretty printer for derived class objects?
I have attempted to make a pretty printer for a number of objects deriving from a class; but I have arrived at some behavior that puzzles me - I hope I can get some help to understand (and fix) it. ...
0
votes
0
answers
30
views
Python assign inherited class [duplicate]
I have a class A that has many attributes, lets call them a,b,c,...,z
Then I have a class B that inherites from A. Inside a function in B I want to set all the self attributes of A to another instance ...
-2
votes
3
answers
85
views
How to correctly implement a 'Child' class that extends a 'Parent' class and inherits a class field from the latter?
This is my task
Implement a Child class that extends the Parent.
Add a constructor to the Child class can calls super().
Implement a new function addNewAbilities(newAbility) in the Child class where ...
0
votes
1
answer
137
views
Inherit the class code, but NOT the layout and design of a Delphi form?
I have a form TMyForm. Now I want to make a new form TNewForm which inherits TMyForm's code (.pas), but not the layout and design (.dfm). Is that possible?
Since the new form has a completely ...