//Jason Winnebeck v1, 12/9/98
//This program is totally freeware
//Small program to see when variables are copied in classes, and the role of
// The copy constructor, and the = sign.

#include <iostream.h>
#include <conio.h>

class Int {
private:
  int dat;
public:
  Int() {cout << "Copy Constructor" << endl;}
  Int(int d) {dat = d; cout << "Copy Constructor (with int)" << endl;}
  Int(const Int& d) {dat = d.dat; cout << "Copy Constructor (with Int)" << endl;}
  ~Int() {cout << "Destructor Called" << endl;}
  Int operator = (const Int &i) {dat = i.dat; cout << "Int = Int" << endl; return Int(i.dat);}
  Int operator = (const int &i) {dat = i; cout << "Int = int" << endl; return Int(i);}
  Int operator + (const Int &i) {dat += i.dat; cout << "Int + Int" << endl; return Int(i.dat + dat);}
  Int operator + (const int &i) {dat += i; cout << "Int + int" << endl; return Int(i + dat);}
  friend ostream& operator << (ostream &o, Int &i) {o << i.dat << "<< op ";}

  Int MyFunc(const Int &i) {
    Int temp(i);
    temp = temp + 10;
    return temp;
  }
};

void main() {
  clrscr();
  cout << "a=0;b=0;c=0;" << endl;
  Int a=0,b=0,c=0;

  c = MyFunc(a);
  cout << "Execution Terminates" << endl;
}
