Questions tagged [polymorphism]

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

9 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
0 answers
1k views

Polymorphic deleter for unique_ptr

There is a basic difference in the way C++ manages the deleter for std::unique_ptr and std::shared_ptr, mainly for allowing ...
Amir Kirsh's user avatar
3 votes
0 answers
1k views

POLYMORPHISM - Design a database connection and command

> Exercise 1: Design a database connection To access a database, we need to open a connection to it first and close it once our job is done. Connecting to a database depends on the type of the ...
Milliorn's user avatar
  • 620
3 votes
0 answers
510 views

Replacing dynamic polymorhism with static polymorphism in C++

Motivated due to the fact, that the avr-g++ places the vtables in RAM, I wrote a replacement using static polymorphy. Consider the following example: ...
wimalopaan's user avatar
3 votes
0 answers
1k views

Efficient compile-time directed graph

During my research in Rigid Body Dynamics, (where Contact Graphs are used to solve the contact problem) I came across the question if it is possible to define at compile time a directed graph (class) ...
Gabriel's user avatar
  • 323
2 votes
0 answers
64 views

Creating an array of distinct objects with an identical method that can be evaluated (mapped) at compile-time (constexpr)

In a ray tracing project that I'm trying to make compile-time (constexpr) for fun and challenge, I've run into a bit of an issue: I have an object (intersection) that needs to refer to one of a group ...
Sebastian's user avatar
  • 143
2 votes
0 answers
607 views

Rust idiomatic way of polymorphic struct

I've implemented a simple polymorphic structure, which looks a bit ugly and I'm afraid I am missing an idiomatic way of doing it. To describe briefly what I'm trying to achieve here: I would like to ...
Stormherz's user avatar
  • 121
2 votes
0 answers
614 views

Laravel polymorphic usage

I am fairly new to Laravel and have implemented a many to many polymorphic relationship to a model where you have two tables that act as polymorphic references one is for content (text information ...
Mark Watson's user avatar
1 vote
0 answers
41 views

Generic car instantiating pattern to minimize GC

I'm facing the problem of needing to instantiate lots of cars, and I'd like to recycle the cars no longer used. Each one of my car types, which define how each car should be created, are treated as ...
g3trans's user avatar
  • 11
1 vote
0 answers
60 views

Work around for querying type of derived class

I have an application where messages are collected and dispatched to various handlers. Messages are derived from the base class MessageBase, handlers derived from <...
Frank's user avatar
  • 111