I have a class:
class Point3D : public Point{
protected:
float x;
float y;
float z;
public:
Point3D(){x=0; y=0; z=0;}
Point3D(const Point3D & point){x = point.x; y = point.y; z = point.z;}
Point3D(float _x,float _y,float _z){x = _x; y = _y; z = _z;}
inline const Point3D operator+(const Vector3D &);
const Point3D & operator+(const Point3D &point){
float xT = x + point.getX();
float yT = y + point.getY();
float zT = z + point.getZ();
return Point3D(xT, yT, zT);
}
...
When I use it that way:
Point3D point = Point3D(10,0,10);
Everything works fine.
When I write:
Point3D point = Point3D(10,0,10);
Point3D point2 = Point3D(0,0,0) + point();
Also it's ok (point2 = point). When I add something more than (0,0,0) it's also working.
But when I want just to:
Point3D point = Point3D(10,0,10);
someFunction( Point3D(0,0,0) + point ); //will get strange (x,y,z)
The function get value of some (in my opinion) random (x,y,z). Why?
What's even stranger, in that similar example everything will be working again:
Point3D point = Point3D(10,0,10);
Point3D point2 = Point3D(0,0,0) + point;
someFunction( point2 ); // will get (10,0,10)
What's the reason for that strange behaviour?