📄 circle.hpp
字号:
// Circle.hpp
//
// Class for circles.
//
// (C) Datasim Education BV 1998
#ifndef Circle_hpp
#define Circle_hpp
#include "Point.hpp"
class Circle: public Shape
{
private:
// Private functions
void init(const Point& cp, double rds);
// Properties for centerpoint as radius
Point centerpoint; // Center point
double radius; // Radius
public:
// Constructors and destructor
Circle(); // Default constructor
Circle(const Point& cp, double r); // Construct with centerpoint and radius
Circle(const Point& p1, const Point& p2); // Construct circle with two points
Circle(const Circle& source); // Copy constructor
virtual ~Circle(); // Destructor
// Selectors
Point CenterPoint() const; // Return the centerpoint
double Radius() const; // Return the radius
double Area() const; // Calculate the area
double Diameter() const; // Calculate diameter
bool Contains(const Point& p) const; // Does the circle contain the point
double Distance(const Point& p) const; // The distance between the circle and a point
// Special copy function to create a copy of a shape when you only have a shape pointer
virtual Shape* Clone() const; // Create a copy of the shape
// Operator overloading
Circle& operator = (const Circle& source); // Assignment operator
// Friends
friend std::ostream& operator << (std::ostream& os, const Circle& c); // Output circle to ostream
};
#endif // Circle_hpp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -