Tenth to tenth week Project one-point-circle-cylinder Group Design (2)

Source: Internet
Author: User

 /* *copyright (c) 2016, College of Computer and Control engineering, Yantai University *all rights reserved * File name: 123.cpp * Author: Wang Lui * Completion Date: May 6, 2016 * version number: v1.0 * * Problem Description: Point to The base class, which derives a circle class, increases the data member R, and the area of the member function, implements the other required member functions, and designs the main function to complete the test. * Input Description: None. * Program output: Circle Center coordinate, radius and area.                    */#include <iostream>using namespace Std;class point{public:point (double x=0,double y=0);                  Constructor point void SetPoint (double,double);    Set x and Y coordinate values double GetX () {return x;    }//x coordinates double GetY () {return y; }//y coordinates void show ();p rotected://protected member Double X, y;};    void Point::setpoint (double m,double n)//set X and Y coordinate values {x=m; Y=n;}    Point: The constructor {x=m:P oint (double m,double n)//point; Y=n;} void Point::show () {cout<< "(" <<x<< "," <<y<< ")" &LT;&LT;ENDL;}  Class Circle:public Point//circle is the common derived class of the point class {public:circle (double x=0,double y=0,double r=0);                Constructor circle void Setr (double);  Sets the value of the radius double getr ();                   The value of the read RADIUS double area (); Calculates the area of the Circle Void Show ();p rotected:double radius;}; Circle::circle (double m,double n,double R):P oint (m,n), radius (r) {}//define constructor void Circle::setr (Double R)//set radius value {Radi Us=r;} Double Circle::getr ()//Read RADIUS value {return radius;} Double Circle::area ()//Calculate the area of the circle {return radius*radius*3.14159;} void Circle::show ()//output point and Circle area {cout<< "point= (" <<x<< "," <<y<< "), r=" <<radius << ", area=" <<area () <<endl;}    int main () {Circle C (all-in-all);    cout<< "Circle Center, Radius, area:" <<endl;    C.show ();    C.setpoint (2,1);    C.SETR (5);    cout<< "changed Circle Center, radius, area:" <<endl;    C.show (); return 0;}
Operation Result:

Tenth to tenth week Project one-point-circle-cylinder Group Design (2)

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.