-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'。 –
...或写'使用命名空间标准;' –