0

How can i do this?((

The challange task with class Cube, and pow, and there is surf_area and volume

2nd Aug 2017, 2:51 PM
Vladyslav Sabadakh
Vladyslav Sabadakh - avatar
5 Answers
0
could you be a bit more clearer with your question? // header files: iostream, math class Cube { float a; // a is side of cube float surf_area, volume; public: Cube() // default constructor { cin>>a; surf_area=0.0; volume=0.0; } int surf_a() { surf_area = 6*pow(a,2); cout<<"surface area of Cube: "<<surf_area; return 0; } int vol() { volume = pow(a,3); cout<<" volume of Cube: "<<volume; return 0; } } // hope this helps
3rd Aug 2017, 11:22 AM
Rahul George
Rahul George - avatar
0
ill check, but could you explain 2 lines, 6*pow... and pow(a,3)?))
3rd Aug 2017, 11:43 AM
Vladyslav Sabadakh
Vladyslav Sabadakh - avatar
0
@Vladyslav pow in CPP is similar to <sup><\sup> in html. now, 6*pow(a,3) means the same as 6*a*a or 6*a^2 pow(a,3) <=> a*a*a or a^3
3rd Aug 2017, 11:58 AM
Rahul George
Rahul George - avatar
0
no, i know, i want to now why this * to 6 and all like it
3rd Aug 2017, 11:59 AM
Vladyslav Sabadakh
Vladyslav Sabadakh - avatar
0
I suppose that the formula for surface area of a cube is 6*a^2 and that for volume is a^3
3rd Aug 2017, 12:06 PM
Rahul George
Rahul George - avatar