I have this class:
class Object
{
public:
private:
float _positionX, _positionY, _positionZ;
}
I need to do check and do some math every time a new value is assigned to them, and I also use these values in various places. I'm looking for an easier way to assign and check values than having these methods:
class Object
{
public:
float GetPositionX();
void SetPositionX(float value);
//etc
private:
float _positionX, _positionY, _positionZ;
}
So I'm trying to do something like this:
static class Vector3
{
public:
Vector3(float *valueX, float *valueY, float *valueZ)
{
_valueX = valueX;
_valueY = valueY;
_valueZ = valueZ;
}
private:
float *_valueX, *_valueY, *_valueZ;
}
class Object
{
public:
Vector3 Position;
//Position = Vector3(&_positionX, &_positionY, &_positionZ);
private:
float _positionX, _positionY, _positionZ;
}
Just so I can call it like this anywhere else in the code:
Object *myObj = new Object();
myObj->Position.x = 1; //assign, checks are done here
float myValue = myObj->Position.x; //receive, no checks needed
But the compiler complains that Vector3 doesn't have a default constructor. I also have a bunch of Object, and I'm not sure if I'm using the static Vector3 the right way (if it won't conflict with other object's values).
How can I get this working?