Question: Using this circle class: // Circle.h #pragma once #include #include #ifndef CIRCLE_H #define CIRCLE_H using namespace std; const double PI = 3.1416; class circleType {

Using this circle class:

// Circle.h

#pragma once

#include

#include

#ifndef CIRCLE_H

#define CIRCLE_H

using namespace std;

const double PI = 3.1416;

class circleType

{

public:

void print();

// output radius, circumference, and area of the circle

void setRadius(double r);

// Function to set Radius

// Postcondition: if (r >= 0) radius = r;

// Otherwise radius = 0

double getRadius();

// Function to return the radius

// Postcondition: The value of the radius is returned

double area();

// Function to return the area of the circle

// Postcondition: area is calculated and returned

double circumference();

// Function to return the circumference of a circle

// Postcondition: Circumference is calculated and returned

circleType(double r = 0);

// Constructor with a default parameter

// Radius is set according to the parameter

// Default value of the radius is 0.0;

// Postcondition: radius = r;

private:

double radius;

};

#endif

// Circle.cpp

#include "Circle.h"

#include

using namespace std;

void circleType::print()

{

cout << "Radius = " << radius

<< ", area = " << area()

<< "circumference = " << circumference();

}

void circleType::setRadius(double r)

{

if (r >= 0)

radius = r;

else

radius = 0;

}

double circleType::getRadius()

{

return radius;

}

double circleType::area()

{

return PI * radius * radius;

}

double circleType::circumference()

{

return 2 * PI * radius;

}

circleType::circleType(double r)

{

setRadius(r);

}

Use the class to perform the following:

a)

Overload the pre and post increment operator (++) to increment the radius of

the circleType object. Note that after incrementing the radius, it must be

positive.

b)

Overload the pre and post decrement operator (--) to decrement the radius of

the circleType object. Note that after decrementing the radius, it must be

positive.

c)

Overload the binary operator to subtract radius of one circleType object

from corresponding radius of another circleType object. If the resulting

value is negative, display message that operation cant be performed.

d)

Overload == and != to compare two circleType objects. You only need to

compare the radius.

e)

Also overload > , < , >= and <=

Lastly, write test program to test the work shown above.

Edit: overloaded operator functions should be member functions

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!