Can you spot anything wrong with this class/structure?
I use a game engine using MSVC++ .net 2003 and have no problems. Some users
of DevC++ who use the same engine crash at times when a copy of this
structure is the return variable. I don't have access to the code that is
crashing, but the developer has been changing functions that return the
structure to return something else because of this problem.
Personally, I don't see anything wrong with this structure and can't imagine
why it would be crashing in DevC++.
Aside from the all caps used outside of a macro which is frowned upon, can
you spot anything wrong with this strucutre? It looks perfectly legitimite
to me. ( I know the consructor should be using an initializer list and I've
suggested that ).
struct JVEC2
{
JVEC2(float x=0,float y=0){this->x=x;this->y=y;}
// Supported operators
JVEC2 operator+(JVEC2 a) const {JVEC2 temp;temp.x = x + a.x;temp.y = y +
a.y;return temp;}
JVEC2 operator-(JVEC2 a) const {JVEC2 temp;temp.x = x - a.x;temp.y = y -
a.y;return temp;}
JVEC2 operator*(JVEC2 a) const {JVEC2 temp;temp.x = x * a.x;temp.y = y *
a.y;return temp;}
JVEC2 operator/(JVEC2 a) const {JVEC2 temp;temp.x = x / a.x;temp.y = y /
a.y;return temp;}
JVEC2 operator+(float a) const {JVEC2 temp;temp.x = x + a;temp.y = y +
a;return temp;}
JVEC2 operator-(float a) const {JVEC2 temp;temp.x = x - a;temp.y = y -
a;return temp;}
JVEC2 operator*(float a) const {JVEC2 temp;temp.x = x * a;temp.y = y *
a;return temp;}
JVEC2 operator/(float a) const {JVEC2 temp;temp.x = x / a;temp.y = y /
a;return temp;}
JVEC2 operator+=(JVEC2 a) {x += a.x;y += a.y;return *this;}
JVEC2 operator*=(JVEC2 a) {x *= a.x;y *= a.y;return *this;}
JVEC2 operator-=(JVEC2 a) {x -= a.x;y -= a.y;return *this;}
JVEC2 operator/=(JVEC2 a) {x /= a.x;y /= a.y;return *this;}
JVEC2 operator+=(float a) {x += a;y += a;return *this;}
JVEC2 operator-=(float a) {x -= a;y -= a;return *this;}
JVEC2 operator*=(float a) {x *= a;y *= a;return *this;}
JVEC2 operator/=(float a) {x /= a;y /= a;return *this;}
bool operator == (JVEC2 a) const {if (x == a.x && y == a.y) return true;
else return false;}
bool operator != (JVEC2 a) const {if (x != a.x || y != a.y) return true;
else return false;}
JVEC2 operator + () const {JVEC2 t;t.x=+x;t.y=+y;return t;}
JVEC2 operator - () const {JVEC2 t;t.x=-x;t.y=-y;return t;}
// data
float x,y;
};