// cd.cc   Experiments with constructors and destructors
//        When are they called?   P. Conrad for CISC220 06J

#include "cd.h"

#include <iostream>
using std::cerr;
using std::endl;


CD_C::CD_C(int theX)
{
#ifdef DEBUG_CD
  cerr << "Entering (1) CD_C(int theX); " << endl;
#endif

  x = theX;

#ifdef DEBUG_CD
  cerr << "Exiting (1) CD_C(int theX); " << endl;
#endif
}

CD_C::CD_C()
{
#ifdef DEBUG_CD
  cerr << "Entering (2) CD_C(); " << endl;
#endif

  x = 0;

#ifdef DEBUG_CD
  cerr << "Exiting (2) CD_C(); " << endl;
#endif
}

  

CD_C::CD_C(const CD_C & orig)
{
#ifdef DEBUG_CD
  cerr << "Entering (3) CD_C(const CD_C & orig); (copy constructor) " << endl;
#endif

  x = orig.x;

#ifdef DEBUG_CD
  cerr << "Exiting (3) CD_C(const CD_C & orig); (copy constructor); " << endl;
#endif

}
CD_C & CD_C::operator = (const CD_C & right)
{

#ifdef DEBUG_CD
  cerr << "Entering (4) operator = (const CD_C & right)" << endl;
#endif

  x = right.x;

#ifdef DEBUG_CD
  cerr << "Exiting (4) operator = (const CD_C & right)" << endl;
#endif

  return (*this);

}

CD_C::~CD_C()
{
#ifdef DEBUG_CD
  cerr << "Entering (5) ~CD_C()" << endl;
#endif


#ifdef DEBUG_CD
  cerr << "Exiting (5) ~CD_C()" << endl;
#endif

}



ostream & operator << (ostream & left, const CD_C & right)
{
#ifdef DEBUG_CD
  cerr << "Entering (6) << (ostream & left, const CD_C & right) " << endl;
#endif


  right.print(left);
  return (left);

#ifdef DEBUG_CD
  cerr << "Exiting (6) << (ostream & left, const CD_C & right) " << endl;
#endif

}
