第10週第11週上機実践プロジェクト-プロジェクト1-(2)-点-円-円柱類族の設計
1743 ワード
/*copyright(c)2016.
* All rights reserved,
* :text.Cpp
* :
* :2016 5 7
* :vc++6.0
* :
*/
#include<iostream>
using namespace std;
#define Pi 3.1415926
class Point
{
private:
double x,y;
public:
Point(double x1,double y1):x(x1),y(y1){}
double getX()
{
return x;
}
double getY()
{
return y;
}
void print()
{
cout<<" :"<<x<<" "<<" :"<<y<<endl;
}
};
class Circle:public Point
{
private:
double r;
double area;
double perimeter;
public:
Circle(double x1,double y1,double r1):Point(x1,y1),r(r1){}
void Area()
{
area=Pi*r*r;
}
void Perimeter()
{
perimeter=2*Pi*r;
}
void showRadius()
{
cout<<" :"<<r<<endl;
}
void showArea()
{
cout<<" :"<<area<<endl;
}
void showPerimeter()
{
cout<<" :"<<perimeter<<endl;
}
};
int main()
{
Point p(2.0,3.0);
p.print();
Circle c(2.0,3.0,2.0);
c.Area();
c.Perimeter();
c.showRadius();
c.showArea();
c.showPerimeter();
return 0;
}
:
<img src="http://img.blog.csdn.net/20160507151402016?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
: 。
: , , , 。