// Example 63 #include #include #include using namespace std; // Class declaration... class sphere { public: double x_center, y_center, z_center, radius; double volume( void ); }; double sphere::volume( void ) // :: is the scope resolution operator. // It signifies that volume is a member of sphere class { double V = 4.0 * M_PI * pow( radius, 3 ) / 3.0; return( V ); } int main() { sphere ball; sphere BALL[10]; ball.x_center = 1.0; ball.y_center = 2.0; ball.z_center = -1.0; ball.radius = 5.0; BALL[0] = ball; cout << "The volume of BALL[0] is " << BALL[0].volume() << endl; cout << "\n\n"; system( "PAUSE" ); return( EXIT_SUCCESS ); }