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.

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; ...
s.l's user avatar
  • 175
-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 ...
rxvxl's user avatar
  • 1
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 ...
Mejenborg's user avatar
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 ):...
Pipo's user avatar
  • 4,963
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 ...
TrippLamb's user avatar
  • 1,569
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 ...
stav12212's user avatar
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 ...
Yufei Zheng's user avatar
-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<...
steve89's user avatar
16 votes
1 answer
1k views

How does C++ select the `delete` operator in case of replacement in subclass?

Let's assume I have the following code (https://godbolt.org/z/MW4ETf7a8): X.h #include <iostream> struct X{ void* operator new(std::size_t size) { std::cout << "new X\...
Shady Atef's user avatar
  • 2,339
0 votes
1 answer
100 views

How do you use polymorphism with Go maps?

I'm curious on what kind of patterns should used in Go for such cases. So let's suppose, you have a Request struct that holds some information for making an HTTP request, along with the parameters ...
ansme's user avatar
  • 443
0 votes
0 answers
16 views

Efficient design solution for handling dynamic marking schemes with multiple levels and subjects

We're developing a grading system for a school with multiple levels (e.g., elementary, middle school, high school) and various subjects within each level (n subjects < 200). The challenge is that: ...
shithanshu mishra's user avatar
2 votes
3 answers
154 views

In C++, compared to final or not virtual function, what is the advantage of CRTP?

I'm new to learning modern C++ programming. I have read many blogs and questions but haven't found the answer of this question. In C++, compared to final or not virtual function, what is the advantage ...
CatFood's user avatar
  • 33
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
5 votes
2 answers
108 views

How to change the type of a polymorphic record using lenses?

In the following code snippet, how do I write the toRecordWrite function such that it can work with any DbRecord with similar type-level mechanics, eg. UserPoly id createdAt updatedAt email username ...
Saurabh Nanda's user avatar
0 votes
1 answer
52 views

Accessing Private Members of Derived Class through Base Class Pointer with Virtual Function in C++

I have a scenario in C++ where I'm accessing private members of a derived class through a base class pointer, and it seems to work without any errors. Here's a simplified version of the code: #include ...
Hamza's user avatar
  • 42

15 30 50 per page
1
2 3 4 5
691