(The Circle class) Implement the relational operators < in the Circle class in Listing 9.5 to order the Circle objects according to their radii.

```
class Circle
{
public:
Circle();
Circle(double);
double getArea();
double getRadius();
void setRadius(double);

private:
double radius;
};
```


```
#include
using namespace std;

class Circle
{
public:
// Construct a circle object
Circle::Circle()
{
radius = 1;
}

// Construct a circle object
Circle::Circle(double newRadius)
{
radius = newRadius;
}

// Return the area of this circle
double Circle::getArea()
{
return radius * radius * 3.14159;
}

// Return the radius of this circle
double Circle::getRadius()
{
return radius;
}

// Set a new radius
void Circle::setRadius(double newRadius)
{
radius = (newRadius >= 0) ? newRadius : 0;
}


bool Circle::operator < (const Circle & c)
{
return radius < c.getRadius();
}

bool Circle::operator <= (const Circle & c)
{
return radius <= c.getRadius();
}

bool Circle::operator == (const Circle & c)
{
return radius == c.getRadius();
}

bool Circle::operator != (const Circle & c)
{
return radius != c.getRadius();
}

bool Circle::operator > (const Circle & c)
{
return radius > c.getRadius();
}

bool Circle::operator >= (const Circle & c)
{
return radius >= c.getRadius();
}

private:
double radius;
};



int main()
{
Circle c1(5);
Circle c2(6);

cout << (c1 < c2) << endl;
cout << (c1 <= c2) << endl;
cout << (c1 == c2) << endl;
cout << (c1 != c2) << endl;
cout << (c1 > c2) << endl;
cout << (c1 >= c2) << endl;

return 0;
}
```

Computer Science & Information Technology

You might also like to view...

What activities should the team carry out after the testing sessions?

What will be an ideal response?

Computer Science & Information Technology

If you want to save each layer as a separate file, click File on the Application bar, point to Scripts, and then click __________.

a. Flatten All Layer Effects b. Flatten All Masks c. Export Layers to Files d. Export Files to Layers

Computer Science & Information Technology

When a file or folder is moved from its current location to a new location, Windows copies the selected file or folder.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

What tag pair is used to create a new paragraph?

a. ``` ``` b. ``` ``` c. ```

``` d. ``` ```

Computer Science & Information Technology