inttype.h

来自「高精度加法和减法 我自己写的 主要是实现了IntType类」· C头文件 代码 · 共 64 行

H
64
字号
/* 
 * File:   IntType.h
 * Author: Nova
 *
 * Created on 2008��11��4��, ����3:53
 */

#ifndef _INTTYPE_H
#define	_INTTYPE_H

#include<string>
#include<ostream>
#include<cstdlib>
#include<vector>
#include<iostream>
#include<stdlib.h>
using namespace std;
class IntType
{
public:
    //构造函数
    IntType(const string & s);
    IntType(int);
    IntType(const IntType & rhs);
    IntType();
    //析构函数
    ~IntType(){}
    //调整
    void fix();
    //重载赋值运算符
    const IntType & operator= (const IntType & rhs);
    const IntType & operator+=(const IntType & rhs);
    const IntType & operator-=(const IntType & rhs);
    /*const IntType & operator*=(const IntType & rhs);
    const IntType & operator/=(const IntType & rhs);*/
    //重载算术运算符
    IntType operator+(const IntType & rhs)const;
    IntType operator-(const IntType & rhs)const;
    /*IntType operator*(const IntType & rhs)const;
    IntType operator/(const IntType & rhs)const;*/
    //重载逻辑运算符
    bool operator< (const IntType & rhs)const;
    bool operator<=(const IntType & rhs)const;
    bool operator> (const IntType & rhs)const;
    bool operator>=(const IntType & rhs)const;
    bool operator==(const IntType & rhs)const;
    bool operator!=(const IntType & rhs)const;
    bool operator!( ) const;
    IntType operator+( ) const;
    IntType operator-( ) const;
    //输出函数
    void print(ostream & out)const;
    void input(istream & in);
private:
    void init(const string & s);
    vector<int> storeArray;
    bool signalZ;//符号
};

ostream & operator<<(ostream & out,const IntType &x);
istream & operator>>(istream & in, IntType &x);
#endif	/* _INTTYPE_H */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?