I'm using the Chipmunk physics engine for my C++ project.
Chipmunk has it's own vector, cpVect, which is nothing but a struct { double x, y; };
However I have my own operator overloaded Vector class in my project - and I'd like to use it just as a cpVect and vice-versa, without any conversions
(my class Vector
's only data fields are double x, y
as well)
Currently I use this for implicit conversions (for argument passing, setting a Vector variable to a cpVect, etc.)
inline operator cpVect() { return cpv( x, y ); };
inline Vector( cpVect v ) : x( v.x ), y( v.y ) {}
This works for most things, but has a few problems - for example it isn't compatible for using arrays of the type Vector with cpVect arrays.
For that I currently have to do this:
Vector arrayA[123];
cpVect* arrayB = (cpVect*) arrayA;
- Is it possible by some way to use my Vector as cpVect and vice-versa? Data is identical with both structures, mine only has additional methods.