记录详情

Compile Error

/in/foo.cc: In constructor 'BigInt::BigInt(const string&)':
/in/foo.cc:44:31: error: passing 'const string {aka const std::__cxx11::basic_string<char>}' as 'this' argument discards qualifiers [-fpermissive]
             str = str.substr(1);//substr提取字符串子串
                               ^
In file included from /usr/include/c++/6/string:52:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from /in/foo.cc:1:
/usr/include/c++/6/bits/basic_string.h:633:7: note:   in call to 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
       operator=(basic_string&& __str)
       ^~~~~~~~
/in/foo.cc: In member function 'BigInt BigInt::mul(int)':
/in/foo.cc:55:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < digits.size() || carry>0; i++)
                         ~~^~~~~~~~~~~~~~~
/in/foo.cc:57:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (i < digits.size()) {
                 ~~^~~~~~~~~~~~~~~
/in/foo.cc: In member function 'BigInt BigInt::add(const BigInt&) const':
/in/foo.cc:78:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (i < digits.size())sum += digits[i];
                 ~~^~~~~~~~~~~~~~~
/in/foo.cc:79:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (i < other.digits.size())sum += other.digits[i];
                 ~~^~~~~~~~~~~~~~~~~~~~~
/in/foo.cc: In member function 'BigInt BigInt::subtract(const BigInt&) const':
/in/foo.cc:94:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (i < other.digits.size()) diff -= other.digits[i];
                 ~~^~~~~~~~~~~~~~~~~~~~~
/in/foo.cc: In member function 'BigInt BigInt::operator*(const BigInt&) const':
/in/foo.cc:116:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < other.digits.size(); ++i) {
                         ~~^~~~~~~~~~~~~~~~~~~~~
/in/foo.cc:117:46: error: passing 'const BigInt' as 'this' argument discards qualifiers [-fpermissive]
             BigInt term = mul(other.digits[i]);
                                              ^
/in/foo.cc:51:12: note:   in call to 'BigInt BigInt::mul(int)'
     BigInt mul(int digit)
            ^~~
/in/foo.cc: In function 'std::ostream& operator<<(std::ostream&, const BigInt&)':
/in/foo.cc:154:5: warning: no return statement in function returning non-void [-Wreturn-type]
     }
     ^

信息

递交者
类型
自测
题目
P1023 OO6-1 高精度整数类的乘法运算
语言
C++
递交时间
2024-05-01 12:43:08
评测时间
2024-05-01 12:43:08
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes