template <class type>
class BigInteger
{
private:
const type base = (1 << sizeof(type) * 4) - 1;
vector<type> digits;
public:
friend istream& operator >> (istream& in, BigInteger<type> object);
};
istream& operator >> (istream& in, BigInteger<type> object)
{
string input;
in >> input;
for (auto i = input.rbegin(); i != input.rend(); i++)
{
object.digits.push_back(*i);
}
return in;
}
错误:E0020: идентификатор "type" не определен
在我的情况下如何解决?
重载的输入运算符不是类方法,该运算符只是类的友元函数,因此需要单独编写它的模板,因为函数的特化不依赖于类的特化,反之亦然