c++ - double dispatch infinite loop -


I get double sections for the distance between 2 squares ( B 2 objects) I am using C which are the sub-classes of the second (A) I think that the methods in the class A should be pure virtual, but they are somewhere else Used in a test, so class A should be instantaneous, so I can not make them pure virtual, okay?

One more thing is that I am not sure if I am using a well-dual transmission, because sometimes an infinite loop is generated, in definition (< Double Double (B * B) {return std :: numeric_limits & lt; double} in A>

& Gt; :: Maximum ();} Virtual Double Distance B (C * C) {A- Virtual Double Distance C (C * C) {return std} Virtual Double Distance (C * C) Return

in class B :

B: Distance B * B: Distance B * B: Distance (A * A) {Return A-> Distance (this);} Double B :: Extension B (B * B) {/ * Calculation Distance * Double} B: Distance C (C * C) {Return C-> Distance B (this);}

In class C :

  Double C :: Distance (A * A) {return-> DistanceC (this);} Double C :: Distance B (B * B) {/ * Calculation Distance: Double} Double C: : Distance C (C * C) {/ * Calculation Distance * /}  

 < Code> virtual Force distance (A * A) {return A-> Distance (this);}  

So if I have:

  A * A1, A 2;  

And I call:

  a1-> Distance (A2);  

will call the above implementation

  a2-> Distance (A1);  

who will call:

  a1-> Distance (A2);  

... and this is an infinite loop.


Comments