问题及描述;
/*
*Copyright (c) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称;test.cpp
*作者;邱凯
*完成日期;2016年5月5号
*版本号;v6.0
*问题描述; 点圆柱的设计(2)
*输入描述; 输入数据
*输出描述; 输出答案
*/
#include <iostream>
using namespace std;
class point
{
protected:
double x;
double y;
public:
point(double a=0,double b=0)
{
x=a;
y=b;
}
void setpoint (double a,double b)
{
x=a;
y=b;
}
double getx()
{
return x;
}
double gety()
{
return y;
}
void show()
{
cout<<x<<"."<<y<<endl;
}
};
class Circle:public point
{
protected:
double r;
public:
Circle(double a,double b,double c)
{
x=a;
y=b;
r=c;
}
void setr(double c)
{
r=c;
}
double getr()
{
return 3.14159*r*r;
}
void show()
{
cout<<x<<"."<<y<<r<<endl;
}
};
int main( )
{
Circle c(3.5,6.4,5.2);
cout<<"original circle:\n";
c.show();
c.setpoint(5,5);
cout<<"new circle:\n";
c.show();
return 0;
}
运行结果;