//----------------------------------------------------------------- //Name :- //What :- Classes and objects //Where :- //When :- 30/10/2002 //----------------------------------------------------------------- //includes header files #include #include #include #include //class dedfinition class cylinder_bar { public: cylinder_bar(); //class constructor void get_data(float,float); //function for data input void calculate_volume(); //function to find the volume void calculate_surface(); //function to find the surface void display_results(); //function to display the results ~cylinder_bar(); //class destructor private: float diameter; //declaration of the "diameter" of the class float height; //declaration of the "height" of the class float pi; //declaration of the "pi" of the class float cy_volume; //declaration of the "volume" of the class float cy_surface; //declaration of the "surface" of the class }; //default values for variables by constructor cylinder_bar::cylinder_bar() { diameter = height = cy_volume = cy_surface = 0.0; pi = 3.14159; } //this function inputs the data void cylinder_bar::get_data(float d,float h) { diameter = d; height = h; } //applies formulae for volume of cylinder void cylinder_bar::calculate_volume() { cy_volume = pi * diameter * diameter * height/4; } //applies formulae for surface of cylinder void cylinder_bar::calculate_surface() { cy_surface = (pi * diameter * diameter/2 + pi * diameter * height); } //function to display the results void cylinder_bar::display_results() { cout<<"\n The volume of the cylinder_bar is = "< h) //if to check whether cylinder fits into the cube or not cout<<"\n This cylinder cannot fit into the cube. \n"<< endl; else cout<<"\n This cylinder fits into the cube. "<