// File:   03constParam.cpp for CS319-Week 12
// What:   An example of a const parameter used in operator overloading.

#include <iostream>
#include <string>

class NumberA
{
private:
  double x;
public:
  NumberA() {x=0.0;};
  NumberA(const NumberA &copy) {x=copy.x;}; // notice const
  void set_x(double X) {x=X;};
  double get_x(void) {return(x);};
  NumberA operator+(NumberA &b)
    {
      NumberA sum;
      sum.x = x + b.x;
      return(sum);
    }
};

class NumberB
{
private:
  double z;
public:
  NumberB() {z=0.0;};
  NumberB(const NumberB &copy) {z=copy.z;}; // notice const
  void set_z(double Z) {z=Z;};
  double get_z(void) {return(z);};
  NumberB operator+(const NumberA &b)
    {
      NumberB sum;
      sum.z = z + b.x;
      return(sum);
    }
};

int main(void)
{
  NumberA a;
  a.set_x(121.234);
  NumberA b(a+a);
  std::cout << "a.x= \t" << a.get_x() <<  std::endl;
  std::cout << "b.x= \t" << b.get_x() <<  std::endl;
  return(0);
}
  


  
  
  
