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.

polymorphism
0 votes
0 answers
8 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,549
0 votes
0 answers
14 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
36 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
15 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,329
0 votes
1 answer
97 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
  • 433
0 votes
0 answers
15 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
150 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
104 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
0 votes
0 answers
14 views

Derived class as argument of OpenCL kernel function

I am trying to compile the following OpenCL kernel code with clang-16: clang-16 -cl-std=clc++2021 -c -emit-llvm -target spir64 -Xclang -finclude-default-header \ -o /workspace/test/...
Jackdu0049's user avatar
1 vote
1 answer
31 views

polymorphic type displaying as blank in the inspector

It's not easy to specifically explain what the problem is, and the code through which the problem could be originating is extensive, and I am uncertain how to narrow it down beyond what I already have,...
RWolfe's user avatar
  • 178
-1 votes
0 answers
53 views

How do I implement this properly? A question that involves Java generics, inheritance, and consumers

I'm trying to implement a sort-of Builder pattern that takes in raw data, and depending on what needs to be built, gets a predefined schema with a set of Consumers, specifically targeted for what ...
PVDM's user avatar
  • 116
-1 votes
0 answers
42 views

Is there a way to use `JsonTransformingSerializer` with the base class while letting Kotlin automatically generate the class hierarchy?

I am trying to deserialize a json object that has a recursive hierarchy, however, the json structure does not include type discriminators: ... "ObjectName": { ...
mystm's user avatar
  • 1

15 30 50 per page
1
2 3 4 5
691