In software engineering, double dispatch is a special form of multiple dispatch and a mechanism that dispatches a function call to different concrete functions depending on the runtime types of two objects involved in the call. In most OO systems, the concrete function that is called from a function call in the code depends on the dynamic type of a single object and therefore they are known as single dispatch calls, or simply virtual function calls.
Questions tagged [double-dispatch]
97 questions
0
votes
1 answer
Advice on class structure in a collision detection system
C++ is the first language I've used at all extensively that uses object-orientation, so I'm still a bit new to the idea. I'm trying to port a game library I was working on from Go (which uses interfaces instead of a true OOP system) to C++.
I have a…

Velovix
- 527
- 1
- 6
- 19
0
votes
2 answers
double dispatch infinite loop
I'm using double dispatch to obtain the distance between 2 objects of 2 classes(B, C) that are subclasses of another (A).
I think that the methods in class A should be pure virtual, but them are used in a test elsewhere, so the class A must be…

scepeda
- 451
- 7
- 14
0
votes
1 answer
Java double dispatch and genericity
I need to extend an algorithm which uses extensively the double dispatch pattern.
This algorithm manipulate some different data classes (a lot of classes) and each classes require the same extension.
I don't want to modify the existing data classes…

user2970188
- 37
- 5
0
votes
1 answer
"Double polymorphism" : double dispatch pattern, or just visitor pattern?
I have a
class BC_TOYFD
{
public:
BC_TOYFD( BS_TOYFD * pBS, BC2 dBC2 );
virtual ~BC_TOYFD( void ) ;
BS_TOYFD * _pBS ;
BC2 _dBC2 ;
double _PDA ; // store price down approximation
double _PUA ; //…

Olórin
- 3,367
- 2
- 22
- 42
0
votes
3 answers
templated double-dispatching using function pointers
I’m trying to make a custom collision engine for academic purposes and I got stuck on a general c++ programming issue. I already have all the geometries which work properly and the collision test also working properly.
The engine uses those 2…

tiridactil
- 389
- 1
- 11
0
votes
1 answer
C++ Calling a Double dispatch method with objects that are not relative to each other
I have a series of shape objects that can check if they intersect one another (an intersection is true if any part of either object overlaps the other). This works great with double dispatch because the intersection of two objects can be represented…

Casey
- 10,297
- 11
- 59
- 88
0
votes
2 answers
Double dispatch in Java
I am not sure if i have wrong idea about double dispatch. But this is what i thought:
class A{
void testA( B obj ){
System.out.println( "A-Parent" );
obj.testB();
}
}
class AChild extends A{
void testA( B obj ){
…

broun
- 2,483
- 5
- 40
- 55