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