This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: public: Circle(); Circle(double x_pos, double y_pos, double radius_val); double measure(); double distance(); private: double x, y; double radius; double pi; }; // Class Implementation Circle::Circle(): x(0),y(1),radius(1) { pi = 3.1415926; } Circle::Circle(double x_pos, double y_pos, double radius_val): x(x_pos), y(y_pos), radius(radius_val) { pi = 3.1415926; } double Circle::distance() { return (x0)*(x0) + (y – 0) *(y – 0); } 3. Double a, b; Circle c1, c2; a = c1.distance(); b = c2.distance(); What is the value of a and b? 4. Double a, b; Circle c1(1,2,1), c2(2,1,2); a = c1.distance(); b = c2.distance(); What is the value of a and b? 5. Implement the function measure() (Area) to compute the measure of the circle using pi defined in the class. Solutions 1. A, C, D, E 2. A, B, C, D 3. a = b = 1; 4. a = b = 5; 5. double Circle::measure() { return pi * radius * radius; }...
View
Full Document
 Spring '09
 WangXin
 Subroutine

Click to edit the document details