Tenth to tenth Week Item 2: Point-circle-cylinder Group Design (3)

Source: Internet
Author: User
Tags gety



Questions and codes:

#include <iostream>using namespace Std;const double pi=3.14;class point{public:point (int xx,int yy): X (xx), Y (        yy) {} void setx (int xx) {x=xx;}        void sety (int yy) {y=yy;}        int Getx () {return x;} int gety () {return y;}    Private:int x; int y;}; Class Circle:public point{public:circle (int xx,int yy,double RR):P oint (Xx,yy), R (RR) {} void area () {area=    Pi*r*r;    The area of void PrintArea () {cout<< "circle is:" <<area<<endl;    } double Getarea () {return area;} Double Getr () {return r;}    Private:double R; Double area;}; Class Cylinder:public Circle{public:cylinder (int xx,int yy,double rr,double hh): Circle (XX,YY,RR), H (HH) {} void Area1    () {Area1=getarea () *h;    } void Volume () {Volume=getarea () *2+2*pi*getr () *h;        The volume of void print () {cout<< "cylinder is:" <<area1<<endl;    cout<< "The surface area of the cylinder is:" <<volume<<endl;    }private:double h; Double area1; double volume;};    int main () {Cylinder C (1,2,3,4);    Cout<<c.getx () << "<<c.gety" () <<endl;    C.printarea ();    C.print (); return 0;}


Operation Result:


Summary of Knowledge points:

From this program I learned about a particularly complex program, to learn steps to achieve the idea.

Learning experience:

Don't be discouraged when you have a problem, think more and find a way to solve it.




Tenth to tenth Week Item 2: Point-circle-cylinder Group Design (3)

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.