第1关:完整的包装类
/********** BEGIN **********/
#include <iostream>
#include "Int.h"
#include "IntOp.h"
using namespace std;
Int::Int() {}
Int::Int(const Int&rhs) { value = rhs.value; }
Int::Int(int v) { value = v; }
Int::~Int() { }
int Int::getValue()const { return value; }
void Int::setValue(int v) { value = v; }
Int& Int::operator +=(const Int& rhs) {
this->value += rhs.value;
return *this;
}
Int& Int::operator -=(const Int& rhs) {
this->value -= rhs.value;
return *this;
}
Int& Int::operator =(const Int& rhs) {
this->value = rhs.value;
return *this;
}
Int& Int::operator *=(const Int& rhs) {
this->value *= rhs.value;
return *this;
}
Int& Int::operator /=(const Int& rhs) {
this->value /= rhs.value;
return *this;
}
Int& Int::operator %=(const Int& rhs) {
this->value %= rhs.value;
return *this;
}
Int Int::operator ++(int tmp) {
return Int(value++);
}
Int Int::operator --(int tmp) {
return Int(value--);
}
Int& Int::operator ++() {
value += 1;
return *this;
}
Int& Int::operator --() {
value -= 1;
return *this;
}
/********** END **********/