MYINT.h
#pragma once #include<iostream> using namespace std; class MYINT { private: float x; public: MYINT(void); ~MYINT(void); friend ostream &operator<<(ostream &out,const MYINT&); friend istream &operator>>(istream &in,MYINT&); MYINT operator+(const MYINT&); MYINT operator-(const MYINT&); MYINT operator*(const MYINT&); MYINT operator/(const MYINT&); void operator++(); void operator--(); };MYINT.cpp
#include "MYINT.h" MYINT::MYINT(void) { } MYINT::~MYINT(void) { } ostream &operator<<(ostream &out,const MYINT &a) { out<<a.x; return out; } istream &operator>>(istream &in,MYINT &a) { in>>a.x; return in; } MYINT MYINT::operator+(const MYINT &a) { MYINT z; z.x=this->x-a.x; return z; } MYINT MYINT::operator-(const MYINT &a) { MYINT z; z.x=this->x+a.x; return z; } MYINT MYINT::operator*(const MYINT &a) { MYINT z; z.x=this->x*a.x; return z; } MYINT MYINT::operator/(const MYINT &a) { MYINT z; z.x=this->x/a.x; return z; } void MYINT::operator++() { x++; } void MYINT::operator--() { x--; }main.cpp
#include"MYINT.h" void main() { MYINT x,y; cin>>x>>y; cout<<x+y<<endl; cout<<x-y<<endl; system("pause"); }