/**copyright (c) 2014, College of Computer and Control engineering, Yantai University *all rights reserved.* file name: . cpp* Creator: Lenkidong * Completion Date: March 29, 2014 * Version number: v1.0*/
Problem
Write an object-based program to find the volume and surface area of 5 long Fang. The data members of rectangular column class bulk include length, width (width), height (heigth) and so on.
The work and requirements to be done against the code already given are:
- You need to define a rectangular column class, and the code has given an array of objects consisting of 5 rectangular column objects B;
- The first 3 objects in the B array b[0], b[1], b[2] Direct parameters are initially initialized, the constructor needs to be defined, whereas in initialization, each object provides a different number of arguments and requires a constructor with default arguments (default is 1.0 for parameters not given)
- The 4th Object B[3] is initialized with a default constructor;
- The 5th rectangular column B[4] is defined without initialization, the design member function get_value, the keyboard input is long, wide, high;
- The design member function output, in main, calls out the volume and surface area of these 5 long Fang;
Code
#include <iostream>using namespace Std;class bulk{public: Bulk (double x=1.0,double y=1.0,double z=1.0): Length (x), Width (y), height (z) {} void get (); void display ();p rivate: double length; Double width; double height;}; void Bulk::get () { cout<< "Please enter the length and width height:"; Cin>>length>>width>>height;} void Bulk::d isplay () { cout<< "long" <<length<< "" << "Wide" <<width<< "" << "high" <
Operation Result:
Summary of Knowledge points:
Object array
Learning experience:
Good study Day Day up
Week three-manipulating the rectangular column class with an array of objects