




SPHERE.H
Member variables allocated for each instance of the class are initialized by creating a constructor function.
Member variables are automatically deleted when a class object is deleted.
However, any memory allocated dynamically by the class object must be deleted manually in a destructor function.
Both the constructor and the destructor are named after the class, while the destructor is preceded by a tilda.
Niether the class constructor nor the class destructor have a return type.
class sphere
{
public:
sphere(void) { resetPosition(); diameter = 0.0; }
~sphere(void) {}
void setRadius(float value) { diameter = value*2.0; }
float getRadius(void) { return diameter/2.0; }
protected:
float xPosition;
float yPosition;
float zPosition;
private:
void resetPosition(void) { xPosition = 0.0; yPosition = 0.0; zPosition = 0.0; }
float diameter;
};