错误:与"运算符<<"不匹配(操作数类型为"std::basic_ostream<char>"

error: no match for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’

本文关键字:lt basic std ostream char gt 运算符 不匹配 错误 操作数 类型      更新时间:2023-10-16

我的代码有问题。

void viewall(struct student st[], int itemcount)
{
    int i = 0;
    cout << left << setw(5) << "ID" << setw(20) << "NAME" << setw(5) << "SEX"
            << setw(5) << "Q1" << setw(5) << "Q2" << setw(5) << "AS" << setw(5)
            << "MI" << setw(5) << "FI" << setw(5) << "TOTAL" << "n";
    cout
            << "========================================================================n";
    while (i <= itemcount)
    {
        if (st[i].stnumber != "")
        {
            cout << left << setw(5) << st[i].stnumber << setw(20)
                    << st[i].stname << setw(5) << st[i].sex << setw(5)
                    << st[i].quiz1 << setw(5) << st[i]quiz2 << setw(5) 
                    << st[i].assignment << setw(5) << st[i].midterm
                    << setw(5) << st[i].finale << setw(5) << st[i].total
                    << "n";
        }
        i = i + 1;
    }
}

error: no match for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’<----这就是我犯的错误,我该怎么办?

看起来你有一个拼写错误:

[…]<lt;st[i]quiz2<lt;[…]

更有可能是:

[…]<lt;st[i].quiz2<lt;[…]

注意.(点)