Feb 5, 2013 at 6:35pm UTC
The error message looks like getX/Y/Z are not declared const, so you are not allowed to call them on a const instance, in this case rhs.
Last edited on Feb 5, 2013 at 6:35pm UTC
Feb 5, 2013 at 6:38pm UTC
rhs is a const object.
getX ,
getY and
getZ don't operate on const objects (as they should.)
Solution: change the definition of Vector3, so that
getX ,
getY and
getZ do operate on const objects.
1 2 3 4 5
class Vector3 {
// ...
int getX() const ;
// ...
};
Last edited on Feb 5, 2013 at 6:38pm UTC
Feb 5, 2013 at 7:09pm UTC
I assumed that that couldn't be the problem because I was sure I had declared the getX etc to be const but I look there and you're right I had forgotten to do it. Thanks for the quick response.
Feb 5, 2013 at 7:34pm UTC
Is there any particular reason you are forwarding access to X/Y/Z with getters and setters? It seems pointless in this case.
Feb 6, 2013 at 11:31am UTC
Because I plan to use operators ([]) to access them later and just made these temporarily.