(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;
}
```
You might also like to view...
What activities should the team carry out after the testing sessions?
What will be an ideal response?
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
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)
What tag pair is used to create a new paragraph?
a.
```
``` d. ```