Overloaded Operators Exercise
#include <iostream>
#include <math.h>
using namespace std;
#define PI 3.14159
class Circle{
public:
Circle() : m_Radius( 0.0), m_Area( 0.0) { };
Circle(double r) : m_Radius( r), m_Area( PI*r*r) { };
private:
double m_Radius;
double m_Area;
};
int main(){
Circle largeCir( 33.3), smallCir( 2.2), resultCir;
resultCir = largeCir + smallCir;
cout << largeCir << " + " << smallCir << " = " << resultCir << endl;
resultCir = largeCir - smallCir;
cout << largeCir << " - " << smallCir << " = " << resultCir << endl;
cout << largeCir << " > " << smallCir << ": " << (largeCir > smallCir) << endl;
cout << largeCir << " >= " << smallCir << ": " << (largeCir >= smallCir) << endl;
cout << largeCir << " < " << smallCir << ": " << (largeCir < smallCir) << endl;
cout << largeCir << " <= " << smallCir << ": " << (largeCir <= smallCir) << endl;
cout << largeCir << " == " << smallCir << ": " << (largeCir == smallCir) << endl;
cout << "Enter the radius of a new circle: ";
cin >> resultCir;
cout << "resultCir: " << resultCir << endl;
cout << "++" << largeCir << " = ";
resultCir = ++largeCir;
cout << resultCir << endl;
cout << smallCir << "++ = ";
resultCir = smallCir++;
cout << resultCir << endl;
return 0;
}