declare and define free functions that will take a float/int and output it to the screen in decimal, hex, binary and scientific notation. The values passed will be values returned from member functions of a user defined sphere class.
given an object of a sphere class with a single radius data member. Produce member functions that compute and return values for circumference and volume.
using this class and the free functions print out the data in columns for spheres that have a radii of 20 to 30 in increments of 1.
Then the instructor gives the member functions posted above (I've already written the calculation functions) and says onlyh one sphere object need exist at a time. DO NOT declare an array of sphere objects.
That is the problem as given. I was just confused as to what some of the member functions of the class would be, and given those functions, how would they be implemented.
I made an attempt at a couple, but the confusion stopped me because I also began to wonder how I was going to limit the objects to 20 through 30 given the member functions that he wrote if that's not confusing enough
sphere::sphere() //default constructor
{
int Radius=0;
}
void sphere::setradius(int newRadius)
{
radius = newRadius <= 0 ? 1 : newRadius;
} //to avoid the "0" issue and set a new radius
int sphere::getradius()
{
while (radius <0)
{
cout << "Radius must be a positive value." << endl;
}
return (radius);
// the getter with another means to avoid a 0 radius