//File: circle.cpp #include #include "circle.h" using namespace std; //These methods are accessible anywhere within the scope of //the circle class const double PI=3.14159; //Member functions -- DON'T HAVE THESE IN C circle::circle() //Constructor { m_x=0.0; m_y=0.0; m_rad=1.0; m_name="Unit Circle"; } //Overloaded constructor circle::circle (double xcoord, double ycoord, double radius, string name) { m_x=xcoord; m_y=ycoord; m_rad=radius; m_name=name; } circle::~circle() //Destructor { } //NOTE: Constructors and destructors are called automatically. // You're not permitted to call them yourself. // Also, note that they have no return type. //Accessor Methods double circle::circumference() const //The use of const here prevents //changing or updating the member data. { return (m_rad*2.0*PI); } double circle::radius() const { return m_rad; } string circle::name() const { return m_name; } void circle::center (double & xcoord, double & ycoord) const { xcoord=m_x; ycoord=m_y; } void circle::insert (ostream & out) const { out << m_name << " is located at (" << m_x << ", " << m_y << ")" << endl; out << "Its radius is: " << m_rad << endl; out << "Its circumference is: " << circumference() << endl; out << endl; }