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)