the question is
Create a Sphere class, define its attributes for the radius x coordinate, y coordinate, z coordinate as Center points using double data type, include pi as a constant variable in class. Get the Center values from the user, Calculate its volume by using formula:
Change the radius of the Sphere by specifying the radius value, and display the Center values of a Sphere.
Write a main function () to test it.
in this code i have to declare pi as constant variable.But it gives me this error
error C2512: 'sphere' : no appropriate default constructor available
and a warning
warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
Please help me out..
The class specifies variables for the co-ordinates of the centre (x,y,z).
The variable for the radius is missing.
There may be multiple instances of the sphere object, but just one value of pi. Hence pi should be specified as static.
staticconstdouble pi;
The value needs to be initialised separately. constdouble sphere::pi = 3.1415926535897932385;
and of course it is this constant which should be used in the calculations, rather than the hard-coded value of 3.14. Incidentally, the calculation of volume should use the value of the radius, (currently omitted).
Assuming your executeable is named "j", that would indicate you're trying to execute a project that didn't build. Fix your compile errors and that error shold go away.
If you've previously compiled the source and ran the executable from within the IDE, the linker will be unable to open the target file until the console the executable was run in before is closed and the file is no longer in use.