




SPHERE.H
Although member funtions must be declared within the class declaration, they can be defined later.
The :: directive, preceded by the class name, lets the compiler know to which class the function belongs.
The compiler only requires the type of variable being passed to a member function in the class declaration.
class sphere
{
public:
sphere(void);
~sphere(void);
void setRadius(float);
float getRadius(void);
protected:
float xPosition;
float yPosition;
float zPosition;
private:
void resetPosition(void);
float diameter;
};
sphere::sphere(void)
{
resetPosition();
diameter = 0.0;
}
sphere::~sphere(void)
{
}
void sphere::setRadius(float value)
{
diameter = value*2.0;
}
float sphere::getRadius(void)
{
return diameter/2.0;
}
void sphere::resetPosition(void)
{
xPosition = 0.0;
yPosition = 0.0;
zPosition = 0.0;
}