write the definition of a class sphere containing: A data member radius of type double. A member function called setRadius that accepts a parameter and assigns it to radius. if the parameter is negative, the member function should reverse it to its positive value. The function returns no value. A member function called getRadius that accepts no parameters and returns the value of radius. A member function called getVolume that accepts no parameters and returns the volume of the sphere. A member function called getSurface that accepts no parameters and returns the surface of the sphere
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
write the definition of a class sphere containing:
A data member radius of type double.
A member function called setRadius that accepts a parameter and assigns it to radius. if the parameter is negative, the member function should reverse it to its positive value. The function returns no value.
A member function called getRadius that accepts no parameters and returns the value of radius.
A member function called getVolume that accepts no parameters and returns the volume of the sphere.
A member function called getSurface that accepts no parameters and returns the surface of the sphere.
A class which refers to the one it is a user-defined data type in C++. It can contain data members (variables) and member functions (functions that are declared as members of the class). Member functions which are used to access and modify the data members of the class. Member functions can be declared either in the class definition or outside the class definition, and they can be either static or non-static. Static member functions which do not have access to the data members of the class, while non-static member functions do. Member functions can also be overloaded, meaning they can be declared multiple times with different parameters.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps