Week 5 computer task project 3 (compile an object-based program)

Source: Internet
Author: User
01. /* 02. * copyright and version Declaration of the program part 03. * Copyright (c) 2013, Yantai University Computer college student 04. * All rightsreserved. 05. * file name: bulk. cpp 06. * Author: Zhao guanzhe 07. * Completion Date: April 8, March 29, 2013. * version: v1.0 09. * input Description: 10. * Problem description: 11. */# include <iostream> using namespace std; class Bulk {public: Bulk (double a = 1.0, double B = 1.0, double c = 1.0): length (), width (B), height (c) {}double volune (void); double area (void); void get_value (); void showmessage (); private: double length, width, height ;}; int main () {Bulk B [5] = {Bulk (2.3, 4.5, 6.7), Bulk (1.5, 3.4), Bulk (10.5 )}; // output the volume and surface area of the five long square columns respectively below (int I = 0; I <4; I ++) {cout <"no." <I + 1; B [I]. showmessage ();} B [4]. get_value (); B [4]. showmessage () ;}void Bulk: get_value () {cout <"Enter the length, width, and height of the long column :"; cin> length> width> height;} double Bulk: volune (void) {return (length * width * height);} double Bulk: area (void) {return (2 * length * width + 2 * length * height + 2 * length * width);} void Bulk: showmessage () {cout <"the volume of the column is:" <volune () <"the surface area of the column is:" <area () <endl ;}

Running result:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.