Skip to main content
0 votes
1 answer
72 views

I’m learning Object-Oriented Programming in JavaScript and got confused by the following code: class Animal { constructor(lg) { this.legs = lg; } } class Dog extends Animal { constructor() {...
sylvesterChase's user avatar
0 votes
1 answer
106 views

I have a setup like the following from typing import Generic, TypeVar T = TypeVar("T") class ThirdParty: def __init_subclass__(cls): ... # does not call super() class Mine(...
Daraan's user avatar
  • 5,300
0 votes
0 answers
15 views

How can I move then event handling into the subclass of a JComboBox? I can make it work if everything is in TopLevel but, I want to move the event handling (actionPerformed(ActionEvent e)) into a ...
Xorange's user avatar
  • 11
2 votes
1 answer
181 views

One use of __slots__ in Python is to disallow new attributes: class Thing: __slots__ = 'a', 'b' thing = Thing() thing.c = 'hello' # error However, this doesn’t work if a class inherits from ...
Manngo's user avatar
  • 17.1k
-2 votes
2 answers
93 views

I have five classes. My Main class, a form class, two subclasses that extend the form class and a createForm class I am forced to use to create new instances of the subclass. public class FormenFabrik ...
Wannabree's user avatar
0 votes
0 answers
31 views

I'm relatively new to Java and object oriented programming, and I don't understand why sometimes the constructor used in declaring and object will be a subclass of the objects type instead of the ...
Bluebox's user avatar
  • 13
1 vote
2 answers
110 views

Given this code: class Foo { data = { x: 1 }; } class Bar extends Foo { override data = { ...super.data, y: 1 }; } TypeScript complains on the super.data part: Class field 'data' defined by the ...
user avatar
1 vote
1 answer
70 views

What's the best way in python to create a subclass of an existing class, in such a way that a custom error is raised whenever you attempt to modify the object? The code below shows what I want. class ...
Keplerto's user avatar
  • 121
1 vote
0 answers
80 views

I am in the following situation: I have a type A, two subtypes B and C of A, a function f of type A -> A that is such that for any B object x, f(x) is of type B; for any C object x, f(x) is of ...
Plop's user avatar
  • 161
0 votes
1 answer
29 views

An example of replacing a lambda with a subclass in code is as follows: scale = tf.Variable(1.) scale_layer = tf.keras.layers.Lambda(lambda x: x * scale) Because scale_layer does not directly track ...
joseph king's user avatar
1 vote
1 answer
114 views

I get the following error when creating a custom exception in a C++ module: C:/Sync/Engine/Chorus/Base/win_9x.cpp:600:59: error: conflicting declaration of C function 'void __cxa_throw(void*, void*, ...
Warpspace's user avatar
  • 3,539
0 votes
1 answer
144 views

I'm writing a battleships game for my college project and I want to randomize the positions of the ships in the beginning of the game. My program has an abstract superclass of Ship which branches out ...
okaycomputer's user avatar
1 vote
2 answers
89 views

I want to extend the functionality of a standard list, subclassing seems like the obvious way. Actually, I'm using this to store a mathematical expression in Reverse Polish Notation (RPN) for a ...
Steven Dickinson's user avatar
2 votes
2 answers
264 views

I am using Java 21. I have two classes: abstract class MySuperClass { private final Object mySuperField; MySuperClass(Object myField) { this.mySuperField = myField; } public ...
Amateur Linguist's user avatar
-1 votes
2 answers
55 views

So, I am a total beginner in Java. I need a program that takes a number of players as an input. Then assuming there are 91 domino tiles each with two squares with dots ranging from 0 to 12 in each ...
PabloSaint's user avatar

15 30 50 per page
1
2 3 4 5
279