Operator & and * at function prototype in class

Posted by Puyover on Stack Overflow See other posts from Stack Overflow or by Puyover
Published on 2010-06-17T21:37:03Z Indexed on 2010/06/18 3:23 UTC
Read the original article Hit count: 148

Filed under:

I'm having a problem with a class like this:

class Sprite {
    ...
        bool checkCollision(Sprite &spr);
    ...
};

So, if I have that class, I can do this:

ball.checkCollision(bar1);

But if I change the class to this:

class Sprite {
    ...
        bool checkCollision(Sprite* spr);
    ...
};

I have to do this:

ball.checkCollision(&bar1);

So, what's the difference?? It's better a way instead other?

Thank you.

© Stack Overflow or respective owner

Related posts about c++