foo.cc: In member function ‘BigInt BigInt::operator*(const BigInt&) const’:
foo.cc:75:45: error: no match for ‘operator-’ (operand type is ‘const BigInt’)
75 | return -(BigInt(*this) * BigInt(-other)); // 转换为正数乘法并取反
| ^~~~~~
foo.cc:66:12: note: candidate: ‘BigInt BigInt::operator-(const BigInt&) const’
66 | BigInt operator-(const BigInt& other) const {
| ^~~~~~~~
foo.cc:66:12: note: candidate expects 1 argument, 0 provided
In file included from /nix/gcc-13.2.0/include/c++/13.2.0/string:48,
from /nix/gcc-13.2.0/include/c++/13.2.0/bits/locale_classes.h:40,
from /nix/gcc-13.2.0/include/c++/13.2.0/bits/ios_base.h:41,
from /nix/gcc-13.2.0/include/c++/13.2.0/ios:44,
from /nix/gcc-13.2.0/include/c++/13.2.0/ostream:40,
from iostream:41:
/nix/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator.h:625:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)’
625 | operator-(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/nix/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator.h:625:5: note: template argument deduction/substitution failed:
foo.cc:75:46: note: ‘const BigInt’ is not derived from ‘const std::reverse_iterator<_Iterator>’
75 | return -(BigInt(*this) * BigInt(-other)); // 转换为正数乘法并取反
| ^~~~~
/nix/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator.h:1800:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’
1800 | operator-(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/nix/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator.h:1800:5: note: template argument deduction/substitution failed:
foo.cc:75:46: note: ‘const BigInt’ is not derived from ‘const std::move_iterator<_IteratorL>’
75 | return -(BigInt(*this) * BigInt(-other)); // 转换为正数乘法并取反
| ^~~~~
foo.cc:84:46: warning: comparison of integer expressions of different signedness: ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
84 | int sum = (result.num.size() > i + j + 1) ? (result.num[i + j + 1] - '0') : 0;
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
foo.cc:88:43: warning: comparison of integer expressions of different signedness: ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
88 | if (result.num.size() > i + j + 2) {
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
foo.cc: In member function ‘BigInt BigInt::pow(int) const’:
foo.cc:105:22: error: no match for ‘operator/’ (operand types are ‘int’ and ‘BigInt’)
105 | base = 1 / base; // 注意:这里只是一个示意,实际上需要更复杂的除法逻辑
| ~ ^ ~~~~
| | |
| int BigInt
foo.cc:109:20: error: no match for ‘operator*=’ (operand types are ‘BigInt’ and ‘BigInt’)
109 | result *= base;
| ~~~~~~~^~~~~~~