circle.hpp

来自「financal instrument pricing using c」· HPP 代码 · 共 46 行

HPP
46
字号
// 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

	// 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 + =
减小字号Ctrl + -
显示快捷键?