#include "infint.h"
using namespace std;
Infint::Infint(){
Inf_num='0';
}
Infint::Infint(int i_num){
Inf_num=i_num;
}
Infint::Infint(string s_num){
Inf_num = stoi(s_num); //string to int
}
//Infint::~Infint(){}
Infint& Infint::operator+(int i_num)
{
Inf_num+=i_num;
return *this;
}
Infint& Infint::operator+(string s_num)
{ int temp = stoi(s_num);
Inf_num+=temp;
return *this;
}
Infint& Infint::operator+(const Infint& Inf_o)
{
Inf_num+=Inf_o.Inf_num;
return *this;
}
void Infint::operator=(int i_num)
{
Inf_num=i_num;
}
void Infint::operator=(const Infint& Inf_o)
{
Inf_num=Inf_o.Inf_num;
}
void Infint::operator+=(int i_num)
{
Inf_num+=i_num;
}
void Infint::operator+=(string s_num)
{
int temp = stoi(s_num);
Inf_num+=temp;
}
void Infint::operator-=(int i_num)
{
Inf_num-=i_num;
}
void Infint::operator-=(string s_num)
{
int temp = stoi(s_num);
Inf_num-=temp;
}
void Infint::operator-=(const Infint& inf_o)
{
Inf_num-=inf_o.Inf_num;
}
void Infint::operator++(int)
{
Inf_num++;
}
void Infint::operator--(int)
{
Inf_num--;
}
ostream& operator<<
(ostream& os, const Infint& inf_o)
{
cout<<inf_o.Inf_num;
return os;
}
'C++ > 학교 숙제' 카테고리의 다른 글
string 문자열 덧셈계산 (0) | 2018.04.14 |
---|---|
session_4_ex infint.h(객체 맴버변수가 string 일때) (0) | 2018.04.11 |
session_4_ex infint.cpp(객체 맴버변수가 string 일때) (0) | 2018.04.11 |
session_4_ex infint.h(객체 맴버변수가 int일때) (0) | 2018.04.10 |
session_4_ex (연산자 오버로딩)_문제 (0) | 2018.04.10 |
댓글