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.
polymorphism
10,358
questions
1
vote
0
answers
15
views
How to handle a DTO in both polymorphic and non-polymorphic endpoints with Jackson?
I work with SpringBoot 3.2 and kotlin. I have a usecase for a polymorphic api which I do with some jackson annotations. This already works:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = ...
0
votes
1
answer
69
views
Calling own C++ template function in dylib ends up in identical one in other dylib on Mac
(Note: this is a major revision of the original question after I gained the insight that the original question was a red herring -- it didn't have any answers yet anyway.)
I'm working on an OSX host ...
0
votes
1
answer
42
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;
...
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
22
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
43
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
26
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 ...
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 ...
-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<...
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\...
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 ...
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:
...
2
votes
3
answers
156
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 ...
0
votes
1
answer
76
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 ...
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 ...