Skip to main content

Questions tagged [polymorphism]

In computer science, polymorphism is a programming language feature that allows values of different data types to be handled in a uniform manner.

112 votes
7 answers
120k views

What is polymorphism in JavaScript?

I have read some articles on polymorphism. But I think I could not quite grasp the meaning of its importance. Most of the articles don't say why it is important and how I can achieve polymorphic ...
0 votes
1 answer
39 views

The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter

I've been playing around with TypeScript (I'm still learning) and writing up a few test scenarios to better understand programming fundamentals. export class Base { readonly id: string; ...
9 votes
2 answers
10k views

Polymorphism and overloading with static methods in C#

I have been trying to generate a Factory supposed to return a different object of a common interface (say Item) according to the input parameter (I call it a context) of the function getItem(A context)...
0 votes
1 answer
1k views

Cakephp PolymorphicBehavior errors

I am using a Feedback Plugin from this link to add comments on any model in my application using the PolymorphicBehavior. I am geeting 2 errors on my app that says Strict (2048): Declaration of ...
-1 votes
0 answers
32 views

Polymorphism in Java Spring [closed]

I develop an application in Java Spring. I have an abstract superclass called AbstractPuzzle and I have its children called Wordle and Riddle(I have JOINED type of inheritance). I get an ...
9 votes
1 answer
9k views

Late Binding vs. Polymorphism - what is the difference?

I've seen both used interchangebly but do they really mean the same? From my understanding, Polymorphism stretches the fact that you could exchange an instance of a class by an instance of a subclass, ...
1 vote
0 answers
29 views

Complex multi level EF Core 8 inheritance issue

Please consider the following: DB Context: // DbContext.cs public partial class OperationsDbContext : DbContext { public virtual DbSet<AnimalBase> AnimalBases { get; set; } public virtual ...
0 votes
0 answers
21 views

OpenAPI Swagger with kotlin inheritence

How to deal with inheritence with Kotlin for Swagger targetted objects? Just wondering if there is a way to do something like @Schema(description = "Child.") class Child( aName: String ):...
2 votes
0 answers
41 views

Using Assumed Rank with Unlimited Polymorphic Issues

There must be something I'm misunderstanding. I'm attempting to use an assumed rank unlimited polymorphic variable to store data. When I do this I either get access violations or corrupted data. I ...
0 votes
0 answers
23 views

Cereal archive called from DLL cause polymorphism not to work

I am a newbie to cereal and lately I ran into an odd issue, I have my serialization code inside an external DLL, in the code I use cereal's polymorphism functionality, when trying to invoke the ...
1 vote
1 answer
695 views

Issue correctly using CEREAL_REGISTER_DYNAMIC_INIT in C++ Cereal library

I've moved to using a lib file and wanted to make use of CEREAL_REGISTER_DYNAMIC_INIT properly. I don't know if I need to use this, but I noticed an issue with one of my cerealization types not being ...
0 votes
0 answers
38 views

create object type based on base type member function return value

I am implementing a loadbalancer that should choose balancing strategy based on some logic: class LoadBalancer{ public: bool get_backend_cpu_info(){// some complicate logic involve member ...
37 votes
11 answers
24k views

Reintroducing functions in Delphi

What was the motivation for having the reintroduce keyword in the Delphi Programming Language? If you have a child class that contains a function with the same name as a virtual function in the parent ...
-1 votes
0 answers
56 views

Compiler misidentifying/unrecognising type [duplicate]

I have the following class with constructor: command.h: #include "./robots.h" enum class CMD { //...... }; class CommandTemplate { //..... public: virtual std::unique_ptr<...
19 votes
4 answers
22k views

templates may not be ‘virtual’

Given the code below, the compiler is showing a message pointing that error: templates may not be ‘virtual’. Does anyone have a suggestion on how to solve the bug? template < class FOO_TYPE> ...

15 30 50 per page
1
2 3 4 5
691