-1
我想實現一個可以處理任意大數字的類。我知道我可以使用BigInteger之類的其他庫,但我只是想將自己的事情作爲練習來實現。如何在C++中使用我自己的類中的庫?
我的頭文件:
#ifndef INT_H
#define INT_H
//#ifndef vector
#include <vector>
class Int{
private:
vector<int> v;
public:
Int();
Int(int);
void clear();
void push_back();
void resize();
vector<int>::iterator begin();
vector<int>::iterator end();
int size();
void sum(Int &, Int, Int);
void sub(Int &, Int, Int);
void prod(Int &, Int, Int);
Int operator+(const Int &);
Int operator-(const Int &);
Int operator*(const Int &);
Int operator>(Int &);
Int operator<(Int &);
Int operator>=(Int &);
Int operator<=(Int &);
int& operator[] (Int);
};
//#endif // vector
#endif // INT_H
的問題是它給了我一個錯誤向量的第一次相遇在第9行,即「預期不合格-ID之前‘<’令牌」
任何幫助將非常感激。
編輯:混淆define與include。 現在我得到的矢量沒有命名一個類型
你真的認爲這與你試圖編寫一個大整數類有關嗎? – juanchopanza
將'vector'的所有實例更改爲'std :: vector'。 –
...或寫'使用命名空間標準;' –