Skip to main content

All Questions

Tagged with
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
-3 votes
3 answers
86 views

Why can’t a superclass call a subclass’s methods?

I’m a computer science teacher at a high school, and I’m teaching polymorphism in Java. My students asked me this question, and I didn’t have a good answer. Let’s say I have an Employee class. Also, I ...
Navarun Jagatpal's user avatar
0 votes
1 answer
72 views

Enforcing type safety between concrete subclasses of an abstract base class

I'm facing a type safety issue in my Python project involving an abstract base class (AbstractClass) and its concrete subclasses (ConcreteClassA and ConcreteClassB). Each concrete class implements ...
Adrian's user avatar
  • 153
0 votes
2 answers
38 views

Python sub-class that is inherited by multiple classes

Currently I have a class-definition that looks something like this: class cls_A: def __init__(self, a1, a2, a3): x = a1 + a2 y = a2 + a3 self.__plot__(self) # some ...
joseph praful's user avatar
0 votes
0 answers
44 views

How do I add value to my Method call from my Sub class to Main?

The string value seems to appear yet I can not add a value to my calculations in the fulltime and part time. This is the Main class for my inheritance import java.util.Scanner; public class ...
玉ねぎ忍者's user avatar
0 votes
0 answers
32 views

Java subclass vs superclass inherited variables clarification [duplicate]

ABOUT ME: I am learning Java because I want to become a software developer someday and I came across the topic of subclasses and their ability to inherit from superclasses on tutorialspoint.com. where ...
Nahum Auguste's user avatar
1 vote
1 answer
85 views

Jasmine access protected property

I'm now to angular and have just completed my first implementation of angular inheritance. I need to write a test case for the subclass where I cam assign value to protected variable (coming from base ...
Shweta Shetty 's user avatar
0 votes
1 answer
98 views

How can I programmatically decide what class to create an object as?

I want to write code to communicate with encoders of different positioning styles (absolute vs. relative). The idea I have is to create a base class that has things common to all encoders. Then there ...
tbickford's user avatar
1 vote
2 answers
256 views

How can I "augment" a JS class with methods from another class, without extending it?

I'm writing an app that manages playlists. Basically, my actual logic looks like //define playlist props class Playlist{ public tracks = []; } class ApiPlaylist extends Playlist{ //fill ...
gordie's user avatar
  • 1,865
0 votes
1 answer
52 views

Can we access the members of sub class using the refrenced variable of super class which holds the subclass object? [duplicate]

If not,then for the below program, how is the multiplication(method) of subclass is accessed Since I used the refrence variable of superclass Calculation which holds object of subclass My_Calculation. ...
Sonu Gupta's user avatar
0 votes
2 answers
69 views

C++: overloading method with parameters of multiple subclasses

I am making chess, it's a great way to practice basic OOP. There's an abstract base class Piece with subclasses like King, Rook, Pawn, etc. as well as a Board class. Is there a way to create multiple ...
BENJAMIN GILBERT's user avatar
-2 votes
1 answer
67 views

Subclass declares "no appropriate default constructor available" [closed]

I made a class with a default constructor and a subclass. When I try to create an instance of the subclass using a default constructor, I get the errors C2512 (no appropriate default constructor ...
FoxVocs's user avatar
  • 41
0 votes
1 answer
40 views

How do I solve this missing attribute error in this subclass IceCreamStand in the superclass Restaurant in python?

I am in the middle of learning how to create subclasses to a superclass in python. I have created an IceCreamStand subclass to the superclass Restaurant and then gave the subclass a specific attribute....
Jace's user avatar
  • 9
0 votes
1 answer
63 views

How can I set values from the constructor of the parent class?

I need to create a generic class that is able to dynamically set values based on the properties of the child class. Here are examples: export class EnderecoMobile extends ModelCore{ id: string = '' ...
Diego Souza's user avatar
0 votes
3 answers
85 views

How to manage the Exception thrown from some particular subclasses in Java?

This confusion comes from when I finish my homework. I have tried to give a solution (at the end of this question) but I think it might be a bit fair-fetched. So I was wondering if there's a more ...
catlover's user avatar

15 30 50 per page
1
2 3 4 5
54