diff --git a/voids.cpp b/voids.cpp index 26ff811..882d1c1 100644 --- a/voids.cpp +++ b/voids.cpp @@ -6,7 +6,7 @@ const double pi= 22/7; class Sphere { public: - double radius; + double* radius; double sphere_volume(double radius) { return 4/3 * pi * radius*radius*radius;} /* Volume of sphere= 4/3 * pi * (radius)^3 @@ -18,15 +18,15 @@ class Sphere { */ void exec() { cout << "********* Sphere **********" << endl; - cout << "Surface area: " << sphere_area(radius) << endl; - cout << "Volume: " << sphere_volume(radius) << endl; + cout << "Surface area: " << sphere_area(*radius) << endl; + cout << "Volume: " << sphere_volume(*radius) << endl; cout << "**************************" << endl; } }; class Cube { public: - double side; + double* side; double cube_volume(double side) { return pow(side, 3);} /* Volume of Cube = a ^ 3 @@ -50,17 +50,17 @@ class Cube { */ void exec() { cout << "********* Cube *********" << endl; - cout << "Total Surface area: " << cube_tsa(side) << endl; - cout << "Lateral Surface area: " << cube_lsa(side) << endl; - cout << "Volume: " << cube_volume(side) << endl; - cout << "Length of Diagonal: " << cube_diagonal(side) << endl; + cout << "Total Surface area: " << cube_tsa(*side) << endl; + cout << "Lateral Surface area: " << cube_lsa(*side) << endl; + cout << "Volume: " << cube_volume(*side) << endl; + cout << "Length of Diagonal: " << cube_diagonal(*side) << endl; cout << "************************" <> rad; Sphere mySphere; - mySphere.radius= rad; + mySphere.radius= &rad; cout << endl; mySphere.exec(); } @@ -142,7 +142,7 @@ void three_d_shapes() { cout << "Enter side: "; cin >> side; Cube mycube; - mycube.side= side; + mycube.side= &side; cout << endl; mycube.exec(); } @@ -156,9 +156,9 @@ void three_d_shapes() { cout << "Enter height: "; cin >> hei; Cuboid myCuboid; - myCuboid.len= length; - myCuboid.breadth= bre; - myCuboid.height= hei; + myCuboid.len= &length; + myCuboid.breadth= &bre; + myCuboid.height= &hei; cout << endl; myCuboid.exec(); } @@ -170,8 +170,8 @@ void three_d_shapes() { cout << "Enter height: "; cin >> heig; Cylinder myCylinder; - myCylinder.radius= radi; - myCylinder.height= heig; + myCylinder.radius= &radi; + myCylinder.height= &heig; cout << endl; myCylinder.exec(); } @@ -191,4 +191,4 @@ void three_d_shapes() { int main() { three_d_shapes(); return 0; -} \ No newline at end of file +}