Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are provided with the following 3 files: Base Class Point.h header file for a point class Point.cpp implementation file for a point class Derived

You are provided with the following 3 files:

Base Class

Point.h header file for a point class

Point.cpp implementation file for a point class

Derived Class

Circle.h header file for a derived class (inherits from the point class) in this file you will find comments that tell you what each function should accomplish

Add these 3 files to a C++ project

Create a new file Circle.cpp and add it to the project. In this file you will implement (write) all the functions that are declared in the Circle.h file. You may choose to write some of them inline in the Circle.h (header file), but most will need to be written in the Circle.cpp (implementation file).

Create a new file lastname7.cpp and add it to the project. This file will contain you main program and your main program will do the following:

Create two circle objects c1 and c2

Circle c1 will be set to the following values: x is 1, y is 2, and radius is 3

Circle c2 will be set to the following values: x is 4, y is 5, and radius is 6

Display c1 using the output operator

Display c2 using the output operator

// Point Class Header File // Filename: point.h #include  using namespace std; class Point { private: double x; double y; public: Point(); Point(double xval, double yval); void setPoint(double xval, double yval); double getX() const { return x; } double getY() const { return y; } friend ostream& operator<<(ostream& cout, Point right); };

//point.cpp

#include  #include "Point.h" using namespace std; Point::Point() { x = 0; y = 0; } Point::Point(double xval, double yval) { x = xval; y = yval; } void Point::setPoint(double xval, double yval) { x = xval; y = yval; } ostream& operator<<(ostream& cout, Point right) { cout << '(' << right.x << ", " << right.y << ')'; return cout; }
// Class Circle Header File // Filename: circle.h #include  using namespace std; #include "point.h" class Circle : public Point { private: double radius; public: Circle(); Circle(double xval, double yval, double rval); // uses parameters to set x to xval, y to yval and radius to rval void setRadius(double rval); // sets radius to rval double getRadius() const; // returns radius double getCircumference() const; // returns circumference (2 * radius * 3.14159) double getArea() const; // returns area (3.14159 * radius * radius) friend ostream& operator<<(ostream& cout, Circle right); // displays the following information about a circle: center point (x,y), radius, circumference, and area with a precision of 1 };

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions