<file_sep>#include "Shape.h"

class Circle : public Shape
{
public:
  Circle(const double & = 1);

  void setRadius(const double &);
  double getRadius()const;

  virtual double Area()const override;

private:
  double mRadius;
};
<file_sep>#include <iostream>
#include <iomanip>
#include "Complex.h"
using namespace std;

Complex::Complex(const double &figureA, const double &figureB)
{
  setFigureA(figureA);
  setFigureB(figureB);
}

void Complex::display() const
{
  cout << fixed << setprecision(3);
  cout << "(" << getFigureA() << ", " << getFigureB() << ")";
}

void Complex::setFigureA(const double &figureA)
{
  this->figureA = figureA;
}

double Complex::getFigureA() const
{
  return this->figureA;
}

void Complex::setFigureB(const double &figureB)
{
  this->figureB = figureB;
}

double Complex::getFigureB() const
{
  return this->figureB;
}

Complex Complex::operator +=(const Complex &otherComplex)
{
  this->setFigureA(this->getFigureA() + otherComplex.getFigureA());
  this->setFigureB(this->getFigureB() + otherComplex.getFigureB());
  return *this;
}
Complex Complex::operator +(const Complex &otherComplex) const
{
  return Complex((this->getFigureA() + otherComplex.getFigureA()),
  this->getFigureB() + otherComplex.getFigureB());
}

Complex Complex::operator -=(const Complex &otherComplex)
{
  this->setFigureA(this->getFigureA() - otherComplex.getFigureA());
  this->setFigureB(this->getFigureB() - otherComplex.getFigureB());
  return *this;
}

Complex Complex::operator -(const Complex &otherComplex) const
{
  return Complex((this->getFigureA() - otherComplex.getFigureA()),
  this->getFigureB() - otherComplex.getFigureB());
}

bool Complex::operator ==(const Complex &otherComplex) const
{
  if(this->getFigureA() == otherComplex.getFigureA() &&
    this->getFigureB() == otherComplex.getFigureB()){
      return true;
  }
  else{
    return false;
  }
}

bool Complex::operator !=(const Complex &otherComplex) const
{
  if(this->getFigureA() != otherComplex.getFigureA() ||
    this->getFigureB() != otherComplex.getFigureB()){
      return true;
  }
  else{
    return false;
  }
}
<file_sep>#ifndef BASEPLUS_H
#define BASEPLUS_H

#include <string>
#include "CommissionEmployee.h"

class BasePlusCommissionEmployee : public CommissionEmployee
{
public:
   BasePlusCommissionEmployee( const std::string &, const std::string &,
      const std::string &, const int &, const int &, const int &, double = 0.0,
      double = 0.0, double = 0.0 );
   virtual ~BasePlusCommissionEmployee() { }

   void setBaseSalary( double );
   double getBaseSalary() const;

   virtual double earnings() const override;
   virtual void print() const override;
private:
   double baseSalary;
};

#endif
<file_sep>#include "banana.h"
using namespace std;

Banana::Banana(bool ripe)
{
	this->ripe = ripe;
}

bool Banana::isRipe()
{
	return this->ripe;
}

bool Banana::operator==(Banana& otherBanana){
	if (this->isRipe() == otherBanana.isRipe()){
		return true;
	}
	else{
		return false;
	}
}

ostream& operator<<(ostream &output, Banana &banana){
	output << "A ";
	if (banana.isRipe()){
		output << "ripe ";
	}
	else {
		output << "rotten ";
	}
	output << "banana";
	return output;
}<file_sep>#include "Circle.h"

class Cylinder : public Circle
{
public:
  Cylinder(const double & = 1, const double & = 1);

  void setHeight(const double &);
  double getHeight()const;

  virtual double Area()const override;
  virtual double Volume()const override;

private:
  double mHeight;
};
<file_sep>// Lab 1 Driver Program - used to test the 3 classes
// File Name: MainProg.cpp
// Author: <NAME> 
// Date: Jan 16, 2013

#include "Cylinder.h"

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	Shape    shpeObj;  // instantiate a Shape object

	cout << "The Shape object count is: " << Shape::getObjectCount() << '\n';

	Circle   crclObj;  // instantiate a Circle object
	Cylinder cyldObj;  // instantiate a Cylinder object

	// Count will be 3 in statement below because a Shape object is contained
	//     within each Circle and Cylinder object as well.
	cout << "The Shape object count is: " << Shape::getObjectCount() << "\n";

	Shape * shpePtr = &cyldObj;   // declare a Shape pointer
	                      // and have it point to the Cylinder object
	Shape & shpeRef = cyldObj;  // declare a Shape reference
	                      // and have it reference the Cylinder object

	// The above 2 statments are ok because a derived class object IsA base class object!

	// No additional objects created, so the count is still the same.
	cout << "The Shape object count is: " << Shape::getObjectCount() << "\n";

	// Dynamically create 2 Shape objects
	Shape * shpePtr2 = new Shape;
	Shape & shpeRef2 = *new Shape; 

	// The count should now be 5
	cout << "The Shape object count is: " << Shape::getObjectCount() << "\n";

	// Now destroy the 2 dynamically created objects!
	delete shpePtr2;
	delete &shpeRef2;

	//The count should now be 3 again.
	cout << "The Shape object count is: " << Shape::getObjectCount() << "\n\n";
       
	// Test Shape class

	shpeObj.setNoOfSides(0);

	cout << fixed << setprecision(4); // force use of decimal point and 4 digits of 
	                                  //     precision after the decimal place
	cout << "The number of sides   is: " << shpeObj.getNoOfSides() << "\n\n";
	cout << "The area   of shpeObj is: " << shpeObj.Area() << '\n';
	cout << "The volume of shpeObj is: " << shpeObj.Volume() << "\n\n\n";

	// Test Circle class

	crclObj.setRadius(3.0);

	cout << "The radius of crclObj is: " << crclObj.getRadius() << "\n\n";
	cout << "The number of sides   is: " << crclObj.getNoOfSides() << "\n\n";
	cout << "The area   of crclObj is: " << crclObj.Area() << '\n';
	cout << "The volume of crclObj is: " << crclObj.Volume() << "\n\n\n";

	// Test Cylinder class

	cyldObj.setRadius(5.5);
	cyldObj.setHeight(2.5);

	cout << "The radius of cyldObj is: " << cyldObj.getRadius() << '\n';
	cout << "The height of cyldObj is: " << cyldObj.getHeight() << "\n\n";
	cout << "The number of sides   is: " << cyldObj.getNoOfSides() << "\n\n";
	cout << "The area   of cyldObj is: " << cyldObj.Area() << '\n';
	cout << "The volume of cyldObj is: " << cyldObj.Volume() << "\n\n";

	// Let us see what happens when we ...

	shpeObj = cyldObj;  // Assign the Cylinder class object to the 
	                    //     Shape class object

	cout << "When we invoke the shpeObj with the Area() method, the result is: " <<
		shpeObj.Area() << '\n';
	cout << "When we invoke the shpePtr with the Area() method, the result is: " <<
		shpePtr->Area() << '\n';
	cout << "When we invoke the shpeRef with the Area() method, the result is: " <<
		shpeRef.Area() << '\n' << endl;

	return 0;
}<file_sep>// Exercise 2 Start: Complex.h
// Declaration of class Complex.
// Member functions are defined in Complex.cpp.
// Author: <NAME>
// Date: Jan 30th, 2014
// Modified: <NAME>
// Date: Apr 30th, 2015

/*

Please note that you normally need to provide a prototype for any global functions used to overload an operator.

This prototype statement is normally appended to the end of the class interface file (the class .h file), but it
must _NOT_ be in the actual class declaration (with the exception of friend statements - see explanation further
on in this paragraph). Why not put the prototype statement in the actual class declaration you ask? Because if it
was, the function would be interpreted as a member function of the class instead of as a global function.

This is what I have done below for the overloaded "+" , "-" and "!=" operators that are
implemented as non-friend global functions. Note that the exception to this rule is when the class offers
friendship to the global function (as with the overloaded << and >> operators). In this case the friend statements
also serve the purpose of providing a prototype statement to the compiler. But I consider it good programming style
to also provide prototypes below the class declaration for these friend functions, even though the compiler
does not require them.

*/

#ifndef Complex_incl
#define Complex_incl
#include <iostream>

class Complex  // Complex class
{
public:
	Complex (double real = 1.0, double imag = 0.0 );  // ctor with
	   // 2 default arguments

	Complex & operator+= (const Complex & RHS ) ; //Adds RHS to the Complex object invoked with this method
	                                      //  (thereby modifying the Complex object) and returns the result
	                                      //  Overloads the "+=" operator
	Complex & operator-= (const Complex & RHS ) ; //Subtracts RHS from the Complex object invoked with this method
	                                      //  (thereby modifying the Complex object) and returns the result
	                                      //  Overloads the "-=" operator

	bool operator == (const Complex & RHS) const; // Overloads "==" operator

	double getReal(void) const;      // Returns real part
	double getImaginary(void) const; // Returns imaginary part

	void setReal(const double &);
	void setReal(std::istream &);
	void setImaginary(const double &);
	void setImaginary(std::istream &);

	void display(void); // Outputs to standard output stream the Complex object
	                    //   in the format: (real_part,imaginary_part)

private:

	double real_part, // represents real part of the Complex object
		imaginary_part;     // represents imaginary part of the Complex object

};

//  The following are global function prototypes and not member functions of the Complex class.
//  They are included here because these functions are closely associated with the Complex class.
//  Their implementation is also in the same .cpp file as the implementation of the Complex
//     class.  This is not required but is the norm in these situations.

// overloads the binary "+" operator through a global function
Complex operator + (const Complex & LHS, const Complex & RHS );

// overloads the binary "-" operator through a global function
Complex operator - (const Complex & LHS, const Complex & RHS );

// overloads the binary "!=" operator through a global function
bool operator != (const Complex & LHS, const Complex & RHS);

std::ostream &operator<<(std::ostream &, const Complex &);
std::istream &operator>>(std::istream &, Complex &);

#endif
<file_sep>class Shape
{
public:
  Shape();
  ~Shape();

  void setNoOfSides(const unsigned int &);
  unsigned int getNoOfSides()const;

  virtual double Area()const;
  virtual double Volume()const;

  static unsigned int getObjectCount();

private:
  unsigned int mNoOfSides;
  static unsigned int objectCount;

  void incrementObjectCount();
  void decrementObjectCount();
};
<file_sep>template<typename T>
bool isEqual(T a, T b)
{
	if (a == b){
		return true;
	}
	return false;
}<file_sep>#include <iostream>
using namespace std;

class Banana
{
	friend ostream& operator<<(ostream &, Banana &);
public:
	Banana(bool = true); // default ctr
	bool isRipe();
	bool operator==(Banana&);
private:
	bool ripe; // is the banana ripe?
};<file_sep>#ifndef DATE_H
#define DATE_H

#include <array>
#include <iostream>

class Date
{
   friend std::ostream &operator<<( std::ostream &, const Date & );
public:
   Date( int m = 1, int d = 1, int y = 1900 );
   void setDate( int, int, int );
   int getMonth() const;
   int getDay() const;
   int getYear() const;
   Date &operator++();
   Date operator++( int );
   Date &operator+=( unsigned int );
   static bool leapYear( int );
   bool endOfMonth( int ) const;
private:
   unsigned int month;
   unsigned int day;
   unsigned int year;

   static const std::array< unsigned int, 13 > days;
   void helpIncrement();
};

#endif
<file_sep>// Exercise 1 Starting Point: Fraction.cpp
// Member-function definitions for class Fraction.
// Author: <NAME> 
// Date: Jan 30th, 2014
// Modified by: <NAME>
// Date: Apr 29th, 2015

#include "Fraction.h"
#include "GCD.h" // template function for calculating greatest common divisor

#include <iostream>
using namespace std;

Fraction::Fraction (void)
:numerator(0),denominator(1)
{
}


Fraction::Fraction ( long long num, long long denom )
:numerator(num),denominator(denom)
{
	simplify();
}

Fraction & Fraction::plusEq (const Fraction & op )
{
	if (denominator != op.denominator )
	{
		long long common_divisor = gcd(denominator,op.denominator);
		numerator *= (op.denominator / common_divisor);
		numerator += op.numerator * (denominator / common_divisor);
		denominator *= (op.denominator / common_divisor);
	}
	else 
	{
		numerator += op.numerator;
	}

	simplify();

	return (*this);
}

Fraction & Fraction::operator+=(const Fraction & op)
{
	if (denominator != op.denominator)
	{
		long long common_divisor = gcd(denominator, op.denominator);
		numerator *= (op.denominator / common_divisor);
		numerator += op.numerator * (denominator / common_divisor);
		denominator *= (op.denominator / common_divisor);
	}
	else
	{
		numerator += op.numerator;
	}

	simplify();

	return (*this);
}

Fraction & Fraction::minusEq (const Fraction & op )
{
	if (denominator != op.denominator )
	{
		long long common_divisor = gcd(denominator,op.denominator);
		numerator *= (op.denominator / common_divisor);
		numerator -= op.numerator * ( denominator / common_divisor);
		denominator *= (op.denominator / common_divisor);
	}
	else
	{
		numerator -= op.numerator;
	}

	simplify();

	return (*this);
}

Fraction & Fraction::operator -= (const Fraction & op)
{
	if (denominator != op.denominator)
	{
		long long common_divisor = gcd(denominator, op.denominator);
		numerator *= (op.denominator / common_divisor);
		numerator -= op.numerator * (denominator / common_divisor);
		denominator *= (op.denominator / common_divisor);
	}
	else
	{
		numerator -= op.numerator;
	}

	simplify();

	return (*this);
}

//Implementation of the timesEq method
//Performs similar operation as the *= operator on the built-in types
Fraction & Fraction::timesEq (const Fraction & op)
{
	numerator *= op.numerator;
	denominator *= op.denominator;

	simplify();  // will make sure that denominator is positive and
	             //   will invoke gcd() function to reduce fraction
	             //   as much as possible

	return (*this); // returns the object which invoked the method
}

Fraction & Fraction::operator *= (const Fraction & op)
{
	numerator *= op.numerator;
	denominator *= op.denominator;

	simplify();  // will make sure that denominator is positive and
	//   will invoke gcd() function to reduce fraction
	//   as much as possible

	return (*this); // returns the object which invoked the method
}

Fraction & Fraction::divideEq (const Fraction & op )
{
	numerator *= op.denominator;
	denominator *= op.numerator;

	simplify();

	return (*this);
}

Fraction & Fraction::operator /= (const Fraction & op)
{
	numerator *= op.denominator;
	denominator *= op.numerator;

	simplify();

	return (*this);
}

Fraction Fraction::negate ( void ) const
{
	return (Fraction(-(numerator), (denominator)));
}

Fraction Fraction::operator-(void)const
{
	return (Fraction(-(numerator), (denominator)));
}

void Fraction::simplify(void)
{
	if (denominator < 0 ) //correct sign if necessay
	{
		numerator = - numerator;
		denominator = - denominator;
	}

	if (numerator == 0 )
	{
		denominator = 1;
	}

	// Reduce by dividing by gcd, if gcd > 1

	else
	{
		long long  gcd_val =  gcd (numerator, denominator);
		if (gcd_val > 1)
		{
			numerator /= gcd_val;
			denominator /= gcd_val;
		}
	}
}

long long Fraction::getNum(void)const
{
	return numerator;
}

long long Fraction::getDenom(void)const
{
	return denominator;
}

void Fraction::display (void)const
{
	cout << numerator << '/' << denominator;
}


<file_sep>// Exercise 1 Starting Point: Main Program - used to "test drive" the Fraction class
// File Name: MainProg.cpp
// Author: <NAME>
// Date: Jan 30th, 2014
// Modified by: <NAME>
// Date: Apr 29th, 2015

#include <iostream>
#include "Fraction.h" // include definition of class Fraction from Fraction.h
#include "GCD.h"      // include definition of gcd template function
using namespace std;

int main()
{
	Fraction A; // create a Fraction object with default ctor
	cout << "The default object is: ";
	A.display();

	Fraction B(1,1024); // create a Fraction object with the non-default ctor
	cout << "\n\nThe non-default object is: ";
	B.display();

	Fraction C(8,-1024); // test to see if the simplify method is invoked from 
	                                //   the non-default ctor
	cout << "\n\n8/-1024 simplified is: ";
	C.display();

	// Test timesEq()
	cout << "\n\n- Test timesEq()";
	A = Fraction(2,3); //Assign new values to Fraction objects
	B = Fraction(3,5);

	// NOTE: Equivalent to:  C = A *= B;
	C = A *= (B);

	cout << "\nA = ";
	A.display();
	cout << "\nB = ";
	B.display();
	cout << "\nC = ";
	C.display();

	// Test divideEq()
	cout << "\n\n- Test divideEq()";
	A = Fraction(2,3);  //Assign new values to Fraction objects
	B = Fraction(-7,3);

	// NOTE: Equivalent to:  C = A /= B;
	C = A /= (B);

	cout << "\nA = ";
	A.display();
	cout << "\nB = ";
	B.display();
	cout << "\nC = ";
	C.display();

	// Test plusEq()
	cout << "\n\n- Test plusEq()";
	A = Fraction(-2,-3);  //Assign new values to Fraction objects
	B = Fraction(8,9);

	// NOTE: Equivalent to:  C = A += B;
	C = A += (B);

	cout << "\nA = ";
	A.display();
	cout << "\nB = ";
	B.display();
	cout << "\nC = ";
	C.display();

	// Test minusEq()
	cout << "\n\n- Test minusEq()";
	A = Fraction(2,3);  //Assign new values to Fraction objects
	B = Fraction(8,9);

	// NOTE: Equivalent to:  C = A -= B;
	C = A -= (B);

	cout << "\nA = ";
	A.display();
	cout << "\nB = ";
	B.display();
	cout << "\nC = ";
	C.display();

	// Test negate()
	cout << "\n\n- Test negateEq()";
	A = Fraction(-2,3);  //Assign new values to Fraction objects
	B = Fraction(8,9);

	// NOTE: Equivalent to:  C = -A;
	C = -A;

	cout << "\nA = ";
	A.display();
	cout << "\nC = ";
	C.display();

	// NOTE: Equivalent to:  C = -B;
	C = -B;

	cout << "\nB = ";
	B.display();
	cout << "\nC = ";
	C.display();

	cout << '\n' << endl;

	return 0;

} // end main

<file_sep>#include "Circle.h"
#include <cmath>

Circle::Circle(const double &radius)
: Shape()
{
  Shape::setNoOfSides(1);
  setRadius(radius);
}

void Circle::setRadius(const double &radius)
{
  if (radius > 0){
    this->mRadius = radius;
  }
}

double Circle::getRadius()const
{
  return this->mRadius;
}

double Circle::Area()const
{
  return M_PI * getRadius() * getRadius();
}
<file_sep>#include "Cylinder.h"
#include <cmath>

Cylinder::Cylinder(const double &radius, const double &height)
: Circle(radius)
{
  Shape::setNoOfSides(3);
  setHeight(height);
}

void Cylinder::setHeight(const double &height)
{
  if(height > 0)
  {
    this->mHeight = height;
  }
}

double Cylinder::getHeight() const
{
  return this->mHeight;
}

double Cylinder::Area()const
{
  return ( 2 * M_PI * Circle::getRadius() * Circle::getRadius()) + ( 2 * M_PI * Circle::getRadius() * getHeight());
}

double Cylinder::Volume()const
{
  return M_PI * Circle::getRadius() * Circle::getRadius() * getHeight();
}
<file_sep>#include <iostream>
#include "Employee.h"
using namespace std;

Employee::Employee( const string &first, const string &last,
   const string &ssn, const int &month, const int &day, const int &year)
   : firstName( first ), lastName( last ), socialSecurityNumber( ssn ),
   birthdate( month, day, year )
{
}

void Employee::setFirstName( const string &first )
{
   firstName = first;
}

string Employee::getFirstName() const
{
   return firstName;
}

void Employee::setLastName( const string &last )
{
   lastName = last;
}

string Employee::getLastName() const
{
   return lastName;
}

void Employee::setSocialSecurityNumber( const string &ssn )
{
   socialSecurityNumber = ssn;
}

string Employee::getSocialSecurityNumber() const
{
   return socialSecurityNumber;
}

Date Employee::getBirthDate() const
{
  return this->birthdate;
}

void Employee::setBirthDate(const int &month,
const int &day, const int &year)
{
  this->birthdate.setDate(month, day, year);
}


void Employee::print() const
{
   cout << getFirstName() << ' ' << getLastName()
      << "\nsocial security number: " << getSocialSecurityNumber();
}
<file_sep>#include <iostream>
#include <string>
#include "equality.h"
#include "banana.h"
using namespace std;

int main()
{
	int intA = 5;
	int intB = 5;
	int intC = 6;

	cout << boolalpha;

	cout << "intA: " << intA << " is equal to intB: " << intB << "? " << isEqual(intA, intB) << endl;
	cout << "intA: " << intA << " is equal to intC: " << intC << "? " << isEqual(intA, intC) << endl;

	string stringA = "hello";
	string stringB = "hello";
	string stringC = "bonjour";

	cout << "stringA: " << stringA << " is equal to stringB: " << stringB << "? " << isEqual(stringA, stringB) << endl;
	cout << "stringA: " << stringA << " is equal to stringC: " << stringC << "? " << isEqual(stringA, stringC) << endl;

	Banana bananaA;
	Banana bananaB;
	Banana bananaC(false);

	cout << "Two bananas that are ripe are considered the equal" << endl;

	cout << "bananaA: " << bananaA << " is equal to bananaB: " << bananaB << "? " << isEqual(bananaA, bananaB) << endl;
	cout << "bananaA: " << bananaA << " is equal to intC: " << bananaC << "? " << isEqual(bananaA, bananaC) << endl;

	return 0;
}<file_sep>class Complex
{
public:
  Complex(const double & = 1.0, const double & = 0.0);
  void display() const;

  void setFigureA(const double &);
  double getFigureA() const;

  void setFigureB(const double &);
  double getFigureB() const;

  Complex operator +=(const Complex &);
  Complex operator +(const Complex &) const;
  Complex operator -=(const Complex &);
  Complex operator -(const Complex &) const;
  bool operator ==(const Complex &) const;
  bool operator !=(const Complex &) const;

private:
  double figureA;
  double figureB;
};
<file_sep>// Exercise 2 start: Complex.cpp
// Member-function definitions for class Complex.
// Author: <NAME>
// Date: Jan 30th, 2014
// Modified: <NAME>
// Date: Apr 30th, 2015

#include "Complex.h"
#include <iomanip>
using namespace std;

ostream &operator<<(ostream &output, const Complex &op)
{
	output << "( " << op.getReal() << ", " << op.getImaginary() << " )";
	return output;
}

istream &operator>>(istream &input, Complex &op)
{
	input.ignore(2);
	op.setReal(input);
	input.ignore(2);
	op.setImaginary(input);
	input.ignore(2);
	return input;
}

void Complex::setReal(istream &input)
{
	input >> this->real_part;
}

void Complex::setImaginary(istream &input)
{
	input >> this->imaginary_part;
}

Complex::Complex ( double real, double imag )
{
	this->real_part = real;
	this->imaginary_part = imag;
}

// overload the "+=" operator
Complex & Complex::operator += (const Complex & op )
{
	this->real_part += op.real_part;
	this->imaginary_part += op.imaginary_part;

	return (*this);
}

// overload the "-=" operator
Complex & Complex::operator -= (const Complex & op )
{
	this->real_part -= op.real_part;
	this->imaginary_part -= op.imaginary_part;

	return (*this);
}

// overload the "==" operator
bool Complex::operator == (const Complex & RHS) const
{
	if (this->real_part != RHS.real_part)
		return false;
	else if (this->imaginary_part != RHS.imaginary_part)
		return false;
	else
		return true;
}

void Complex::setReal(const double & real_part)
{
	this->real_part = real_part;
}

void Complex::setImaginary(const double & imaginary_part)
{
	this->imaginary_part = imaginary_part;
}

double Complex::getReal(void) const
{
	return this->real_part;
}

double Complex::getImaginary(void) const
{
	return this->imaginary_part;
}

void Complex::display (void)
{
   // set floating-point number format
   cout << fixed << setprecision(3);

   cout << "( " << this->getReal() << " , " << this->getImaginary() << " )";
}
// overloads the binary '+' operator through a global function
Complex operator + (const Complex & LHS, const Complex & RHS )
{
	Complex temp = LHS;
	temp += RHS; // uses the overloaded "+=" operator
	return temp;
}

// overloads the binary '-' operator through a global function
Complex operator - (const Complex & LHS, const Complex & RHS )
{
	Complex temp = LHS;
	temp -= RHS; // uses the overloaded "-=" operator
	return temp;
}

// overloads the binary "!=" operator through a global function
bool operator != (const Complex & LHS, const Complex & RHS)
{
	return !(LHS == RHS); // uses overloaded "==" operator
}
<file_sep>#include "Shape.h"

unsigned int Shape::objectCount = 0;

Shape::Shape()
{
  setNoOfSides(0);
  incrementObjectCount();
}

Shape::~Shape()
{
  decrementObjectCount();
}

void Shape::setNoOfSides(const unsigned int &noOfSides)
{
    if (noOfSides >= 0){
      this->mNoOfSides = noOfSides;
    }
}

unsigned int Shape::getNoOfSides()const
{
  return this->mNoOfSides;
}

double Shape::Area()const
{
  return 0;
}

double Shape::Volume()const
{
  return 0;
}

unsigned int Shape::getObjectCount()
{
  return objectCount;
}

void Shape::incrementObjectCount()
{
  objectCount++;
}

void Shape::decrementObjectCount()
{
  if (objectCount > 0){
    objectCount--;
  }
}
<file_sep>// Main Program - used to "test drive" the Complex class
// File Name: MainProg_P2.cpp
// Author: <NAME>
// Date: Date: Jan 30th, 2014
// Modified: <NAME>
// Date: Apr 30th, 2015

#include "Complex.h" // include definition of class Complex from Complex.h
using namespace std;

int main()
{
	// Test constructor -NOTE: your Complex class should have only
	//     one constructor.  Your constructor should have default arguments
	//     for the real and imaginary parts of the complex object.

	Complex A; // create a Complex object using default arguments
	cout << "The default object is: " << A;

	Complex B(-2.45, 1.0); // create a Complex object supplying values to the ctor
	cout << "\n\nThe non-default object is: " << B;

	Complex C(25.777,-35.668); // create another Complex object supplying values to the ctor
	cout << "\n\nThe second non-default object is: " << C;

	// Test overloaded += operator
	cout << "\n\n- Test overloaded += operator";
	A = Complex(-25.44,-3.543);  //Assign new values to Complex objects
	B = Complex(30.3,-34.876);

	C = A += B;

	cout << "\nA = " << A;
	cout << "\nB = " << B;
	cout << "\nC = " << C;

	// Test overloaded -= operator
	cout << "\n\n- Test overloaded -= operator";
	A = Complex(4.65,3.789);  //Assign new values to Complex objects
	B = Complex(6.78,9.222);

	C = A -= B;

	cout << "\nA = " << A;
	cout << "\nB = " << B;
	cout << "\nC = " << C;

	// Test overloaded + operator
	cout << "\n\n- Test overloaded + operator";
	cout << "\nEnter a value for A: ";
	cin >> A;
	cout << "\nEnter a value for B: ";
	cin >> B;

	C = A + B;

	cout << "\nA = " << A << "  <== is this correct?";
	cout << "\nB = " << B << "  <== is this correct?";
	cout << "\nC = " << C << "  <== is this correct?";

	// Test overloaded - operator
	cout << "\n\n- Test overloaded - operator";
	cout << "\nEnter a value for A and B: ";
	cin >> A >> B;

	C = A - B;

	cout << "\nA = " << A << "  <== is this correct?";
	cout << "\nB = " << B << "  <== is this correct?";
	cout << "\nC = " << C << "  <== is this correct?";

	// Test overloaded == and != operators
	cout << "\n\n- Test overloaded == and != operators";
	A = Complex(4.65,3.789);  //Assign new values to Complex objects
	B = Complex(6.78,9.222);

	if (A == B)
		cout << "\nA is equal to B" << '\n';
	else
		cout << "\nA is not equal to B" << '\n';

	if (A != B)
		cout << "A is not equal to B" << '\n';
	else
		cout << "A is equal to B" << '\n';

	cout << "\nA = " << A;
	cout << "\nB = " << B;

	A = Complex(4.65,3.789);  //Assign new values to Complex objects
	B = Complex(4.65,3.789);

	if (A == B)
		cout << "\n\nA is equal to B" << '\n';
	else
		cout << "\n\nA is not equal to B" << '\n';

	if (A != B)
		cout << "A is not equal to B" << '\n';
	else
		cout << "A is equal to B" << '\n';

	cout << "\nA = " << A;
	cout << "\nB = " << B;

	cout << '\n' << endl;

	system("pause");

	return 0;

} // end main
<file_sep>#include <iostream>
#include "Complex.h"

using namespace std;

int main()
{
	Complex A;
	cout << "The default object is: ";
	A.display();

	Complex B(-2.45, 1.0);
	cout << "\n\nThe non-default object is: ";
	B.display();

	Complex C(25.777,-35.668);
	cout << "\n\nThe second non-default object is: ";
	C.display();

	cout << "\n\n- Test overloaded += operator";
	A = Complex(-25.44,-3.543);
	B = Complex(30.3,-34.876);

	C = A += B;

	cout << "\nA = ";
	A.display();
	cout << "\nB = ";
	B.display();
	cout << "\nC = ";
	C.display();

	cout << "\n\n- Test overloaded -= operator";
	A = Complex(4.65,3.789);
	B = Complex(6.78,9.222);

	C = A -= B;

	cout << "\nA = ";
	A.display();
	cout << "\nB = ";
	B.display();
	cout << "\nC = ";
	C.display();

	cout << "\n\n- Test overloaded + operator";
	A = Complex(-25.44,-3.543);
	B = Complex(30.3,-34.876);

	C = A + B;

	cout << "\nA = ";
	A.display();
	cout << "\nB = ";
	B.display();
	cout << "\nC = ";
	C.display();

	cout << "\n\n- Test overloaded - operator";
	A = Complex(4.65,3.789);
	B = Complex(6.78,9.222);

	C = A - B;

	cout << "\nA = ";
	A.display();
	cout << "\nB = ";
	B.display();
	cout << "\nC = ";
	C.display();

	cout << "\n\n- Test overloaded == and != operators";
	A = Complex(4.65,3.789);
	B = Complex(6.78,9.222);

	if (A == B)
		cout << "\nA is equal to B" << '\n';
	else
		cout << "\nA is not equal to B" << '\n';

	if (A != B)
		cout << "A is not equal to B" << '\n';
	else
		cout << "A is equal to B" << '\n';

	cout << "\nA = ";
	A.display();
	cout << "\nB = ";
	B.display();

	A = Complex(4.65,3.789);
	B = Complex(4.65,3.789);

	if (A == B)
		cout << "\n\nA is equal to B" << '\n';
	else
		cout << "\n\nA is not equal to B" << '\n';

	if (A != B)
		cout << "A is not equal to B" << '\n';
	else
		cout << "A is equal to B" << '\n';

	cout << "\nA = ";
	A.display();
	cout << "\nB = ";
	B.display();

	cout << '\n' << endl;

	return 0;

}
