1234567891011121314151617181920212223242526272829
#include<iostream> using namespace std; const double PI = 3.14159265; class Cone{ public: Cone(double r,double h){ radius=r; height=h;} double volume (){ return 1/3*height*height*radius*radius*PI; } private: double radius; double height; }; int main() { Cone coneA (3, 4); cout << "Volume of Cone A is: " << coneA.volume() << endl; return 0; }
1234
double volume () { return 1.0 / 3.0 * PI * radius * radius * height; }