Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: Double disp...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 7 Topic 45819 of 47032
Post > Topic >>

Re: Double dispatch (makes no sense!)

by "Victor Bazarov" <v.Abazarov@[EMAIL PROTECTED] > May 8, 2008 at 08:48 PM

saneman wrote:
> I am trying to use double dispatch in the below code:
>
> #include <iostream>
>
> class Box;
> class Sphere;
>
>
> class geometry_type
> {
> public:
>   virtual void haps(geometry_type* other)=0;
>   virtual void collideWith(Box* other)=0;
>   virtual void collideWith(Sphere* other) = 0;
> };
>
> class Box : public geometry_type
> {
> [...]
>   virtual void collideWith(Sphere* other) {
>     std::cout << "Sphere collision with Sphere" << std::endl;

Are you sure this output reflects the actual pairing of the
types here?

>   }
> };
> [..]
>
> What goes on in the last two calls?

Instead of looking at debug printouts, step through your code
in a debugger to make sure the correct function is called.

V
-- 
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
 




 7 Posts in Topic:
Double dispatch (makes no sense!)
saneman <ddd@[EMAIL PR  2008-05-09 02:20:57 
Re: Double dispatch (makes no sense!)
Andrey Tarasevich <and  2008-05-08 17:46:12 
Re: Double dispatch (makes no sense!)
"Victor Bazarov"  2008-05-08 20:48:34 
Re: Double dispatch (makes no sense!)
hurcan solter <hsolter  2008-05-09 03:49:57 
Re: Double dispatch (makes no sense!)
saneman <ddd@[EMAIL PR  2008-05-09 10:42:44 
Re: Double dispatch (makes no sense!)
James Kanze <james.kan  2008-05-09 06:16:31 
Re: Double dispatch (makes no sense!)
Daniel Pitts <newsgrou  2008-05-08 18:33:47 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 15:53:28 CDT 2008.