




SPHERE.H
Data encapsulation is achieved by limiting direct access to member variables.
Member variables and functions declared as protected can only be accessed by children of a class.
Member variables and functions declared as private can not be accessed by anyone outside of the class.
class sphere
{
public:
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;
};