//! @file CVector2D.h
#ifndef _JE3D_CVECTOR2D_H_
#define _JE3D_CVECTOR2D_H_
#include "IShared.h"
#include "IObjectStub.h"
namespace JE3D
{
//! The 2D vector class.
template <class T>
class CVector2D
: public virtual IObjectStub
{
public:
//! The 2D vector constructer.
CVector2D(T xPos, T yPos)
: x(xPos), y(yPos)
{
}
//! Sets the X value.
void setX(T newX)
{
x = newX;
}
//! Sets the Y value.
void setY(T newY)
{
y = newY;
}
//! Returns the X value.
T getX(void)
{
return x;
}
//! Returns the Y value.
T getY(void)
{
return y;
}
//! Compares two vectors to see if they're the same.
CVector2D<T> operator ==(const CVector2D &vectorOther)
{
return (x == vectorOther.getX() && y == vectorOther.getY());
}
//! Compares two vectors to see if they aren't the same.
CVector2D<T> operator !=(const CVector2D &vectorOther)
{
return (x != vectorOther.getX() || y != vectorOther.getY());
}
//! Adds two vectors together.
CVector2D<T> operator +(const CVector2D &vectorOther)
{
x += vectorOther.getX();
y += vectorOther.getY();
return this;
}
//! Subtracts two vectors from eachother.
CVector2D<T> operator -(const CVector2D &vectorOther)
{
x -= vectorOther.getX();
y -= vectorOther.getY();
return this;
}
private:
T x; ///< The X value.
T y; ///< The Y value.
};
typedef CVector2D<s8> CVector2DS8; ///< A 2D vector using s8s.
typedef CVector2D<u8> CVector2DU8; ///< A 2D vector using u8s.
typedef CVector2D<s16> CVector2DS16; ///< A 2D vector using s16s.
typedef CVector2D<u16> CVector2DU16; ///< A 2D vector using u16s.
typedef CVector2D<s32> CVector2DS32; ///< A 2D vector using s32s.
typedef CVector2D<u32> CVector2DU32; ///< A 2D vector using u32s.
typedef CVector2D<f32> CVector2DF32; ///< A 2D vector using f32s.
}
#endif
Quote:In member function `JE3D::CVector2D<T> JE3D::CVector2D<T>::operator+(const JE3D::CVector2D<T>&) [with T = JE3D::u16]':| E:\Projects\C++\DIS\code\source\COptionsState.cpp|137|instantiated from here| error: passing `const JE3D::CVector2D<JE3D::u16>' as `this' argument of `T JE3D::CVector2D<T>::getX() [with T = JE3D::u16]' discards qualifiers| error: passing `const JE3D::CVector2D<JE3D::u16>' as `this' argument of `T JE3D::CVector2D<T>::getY() [with T = JE3D::u16]' discards qualifiers| error: conversion from `JE3D::CVector2D<JE3D::u16>* const' to non-scalar type `JE3D::CVector2D<JE3D::u16>' requested|