問題の説明: 演算子のオーバーロードを使用して大きな整数クラスを作成しようとしています。これまでのところは問題ないと思いますが、コンパイルしようとするとこのエラーが発生し続けます。何が問題なのですか?入力のエラーは表示されず、出力のみが表示されます。
エラー: 「bigint::tostring() const」への未定義の参照
#ifndef HEADER_H_INCLUDED
#define HEADER_H_INCLUDED
using namespace std;
class bigint{
public:
bigint(); //default constructor - set this to zero
bigint(int x0);
bigint(int x0, int x1);
bigint(int x0, int x1, int x2);
bigint(int x0, int x1, int x2, int x3);
bigint(int x0, int x1, int x2, int x3, int x4);
string tostring() const;
private:
int v[5];
};
ostream& operator <<(ostream & out, const bigint outpt){
out << outpt.tostring();
return out;
}
istream& operator >>(istream & in, const bigint& inpt){
return in;
} //need to fix this
bigint & operator +(const bigint & ls, const bigint & rs) {
return bigint(ls) + rs;
}//addition operator
bigint & operator -(const bigint & ls, const bigint & rs){
return bigint(ls) - rs;
} //subtraction operator
bool operator <(const bigint & ls, const bigint rs){
return bigint(ls) < rs;
} //use bool because these values can only be true or false
bool operator >(const bigint & ls, const bigint rs){
return bigint(ls) > rs;
}
bool operator >=(const bigint & ls, const bigint rs){
return bigint(ls) >= rs;
}
bool operator <=(const bigint & ls, const bigint rs){
return bigint(ls) <= rs;
}
bool operator ==(const bigint & ls, const bigint rs){
return bigint(ls) == rs;
}
bool operator !=(const bigint & ls, const bigint rs){
return bigint(ls) != rs;
}
#endif // HEADER_H_INCLUDED