python (65.1k questions)
javascript (44.2k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (12.9k questions)
Purposely trying to break Python class inheritance, don't understand why it breaks this way
I'm exploring the limits of Python class inheritance, so I wrote a small test to see how much I can get away with - redeclaring properties and overriding functions.
class A:
val : int = 3
def ...
GoldenJoe
Votes: 0
Answers: 3
Creating a subclass and object at the same time
I am looking for a C# equivalent of a Java idiom.
In Java, if you have an abstract class, you cannot directly create an object of that class; you need to subclass it (and provide an override of the ab...
rwallace
Votes: 0
Answers: 1
creating a superclass object by using subclass' constructor
let's say we have a superclass Person and a subclass Child, I'm ok that
Person a = new Child();
the statement works as Child is a subclass of Person, so it's permitted in java, but I can't stop thinki...
Yu Hu
Votes: 0
Answers: 0
subclass for NameError: name 'side_length' is not defined
class Polygon():
def __init__(self, side_lengths):
self.side_lengths = side_lengths
def perimeter(self):
return sum(self.side_lengths)
def __str__(self):
side_lengths = len(self.side_lengt...
yiqing zhang
Votes: 0
Answers: 0