小编Vas*_*tor的帖子

为什么std :: sort不能在std :: list上运行?

由于std::sorta std::list,我收到以下错误:

line 44         : instantiated from here
line 5258 : error: no match for 'operator-' in '_last -__first'
line 179 : note: candidates are: ptrdiff_t std::operator-(const std::_Bit_iterator_base&, const std::_Bit_iterator_base&)

从以下代码:

int main()
{
    std::list<Student_info> students;
    Student_info record;
    string::size_type maxlen = 0;   // the length of the longest name

    // read and store all the students data.
    while (read(cin, record))
    {
        // find length of longest name
        maxlen = max(maxlen, record.name.size());
        students.push_back(record);
    }

    // alphabetize the student …
Run Code Online (Sandbox Code Playgroud)

c++

2
推荐指数
1
解决办法
610
查看次数

标签 统计

c++ ×1