#include<iostream>
using namespace std;
class Point{
float x,y,z;
public:
Point(float f_x=1.0, float f_y=1.0, float f_z=1.0);
void setXYZ(float X, float Y, float Z);
void setX(float X);
void setY(float Y);
void setZ(float Z);
void getXYZ(float &X, float &Y, float &Z);
float getX();
float getY();
float getZ();
};
Point::Point(float f_x, float f_y, float f_z)
{
x= f_x;
y= f_y;
z= f_z;
}
float Point::getX()
{
return x;
}
float Point::getY()
{
return y;
}
float Point::getZ()
{
return z;
}
void Point::setXYZ(float X, float Y, float Z)
{
setX(X);
setY(Y);
setZ(z);
/*
x=X;
y=Y;
z=Z;
*/
}
void Point::getXYZ(float &X, float &Y, float &Z)
{
x=getX();
y=getY();
z=getZ();
}
void Point::setX(float X)
{
x = X;
}
void Point::setY(float Y)
{
y = Y;
}
void Point::setZ(float Z)
{
z = Z;
}
int main()
{
float x,y,z;
Point mylocation(8,3,4);
mylocation.getXYZ(x,y,z);
cout<<x<< " " << y << " " << z <<endl;
return 0;
}
Output should be
8 3 4
But displays result like
-1.07374e+008 -1.07374e+008 -1.07374e+008
WHY IS SO???? Help