10th, 11 Weeks-Item 1 (3)

Source: Internet
Author: User

Questions and codes:

/*copyright (c) 2016, College of Computer and Control engineering, Yantai University *all rights reserved.* file name: main.cpp* Author: Wang Lin * completion date: May 9, 2016 * version number: v1.0* Problem Description: Then the Circle class as the direct base class, derive a cylinder (cylinder) class, and then increase the data member H (high), and the cylinder surface area of the member function areas and the cylinder volume member function volume, to achieve the required member functions, and design the main function to complete the test.    * Input Description: * Output Description: */#include <iostream>using namespace Std;class point{public:point (double x=0,double y=0); void Show ();p rotected:double x, y;};    Point::P oint (double a,double b) {x=a; Y=b;} void Point::show () {cout<< "[" <<x<< "," <<y<< "]" &LT;&LT;ENDL;}    Class Circle:public point{public:circle (double x=0,double y=0,double r=0);    Double area (); void Show ();p rotected:double radius;}; Circle::circle (double a,double b,double R):P Oint (A, B), radius (r) {}double Circle::area () {return 3.14159*radius*radius ;} void Circle::show () {cout<< "center= (" <<x<< "," <<y<< "), r=" <<radius<< ", Area= "<<area () <<endl;} Class Cylinder:public Circle{public:cylinder (double x=0,doubleY=0,double r=0,double h=0);    Double area ();    void Show (); Double volume ();p rotected:double height;}; Cylinder::cylinder (double a,double b,double r,double h): Circle (a,b,r), height (h) {}double Cylinder::area () {return Circle::area () +2*3.14159*radius*height;} Double Cylinder::volume () {return circle::area () *height;} void Cylinder::show () {cout<< "center: [" <<x<< "," <<y<< "], r=" <<radius<< ", h=" <

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.