1. Given the base class header file point.h // Point Class Header File // Filena
ID: 3533851 • Letter: 1
Question
1. Given the base class header file point.h
// Point Class Header File
// Filename: point.h
#ifndef POINT_H
#define POINT_H
class point
{
public:
point(double init_x = 0.0, double init_y = 0.0); // sets x to init_x and y to init_y
// or uses the default values
void setPoint(double init_x, double init_y); // sets x to init_x and y to init_y
void print() const; // prints a point in the form (x, y)
double getX() const; // returns the value of x
double getY() const; // returns the value of y
private:
double x;
double y;
};
#endif
2. Write the corresponding implementation file point.cpp
3. The derived class circle will inherit from the point class. You are given the header file circle.h
// Class Circle Header File
// Filename: circle.h
#ifndef CIRCLE_H
#define CIRCLE_H
#include "point.h"
class circle: public point
{
public:
circle(double init_x = 0.0, double init_y = 0.0, double r = 0.0);
// uses default parameters to set x to init_x, y to init_y and radius to r
void print() const;
// prints the following information about a circle:
// center point, radius, circumference, area with a precision of 1
void setRadius(double r);
// sets radius to r
double getRadius() const;
// returns radius
double getCircumference() const;
// returns circumference (2 * radius * 3.14159)
double getArea() const;
// returns area (3.14159 * radius2)
private:
double radius;
};
#endif
4. Write the corresponding implementation file circle.cpp
5. Write the driver program lastname7.cpp to accomplish the following:
Explanation / Answer
////point.cpp
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.