簡體   English   中英

錯誤:“operator&lt;&lt;”不匹配(操作數類型為“std::basic_ostream”<char> &#39;

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

我的代碼有問題。

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>' <---- 這是我得到的錯誤,我該怎么辦?

看起來你有一個錯字:

[...] << st[i]quiz2 << [...]

更可能是:

[...] << st[i].quiz2 << [...]

請注意. (點)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題 錯誤:“operator&lt;&lt;”不匹配(操作數類型為“std::ostream {aka std::basic_ostream”<char> }&#39; 和 &#39;void&#39;) 錯誤:'operator&lt;&lt;' 不匹配(操作數類型是 'std::ostream' {aka 'std::basic_ostream<char> '}</char> 錯誤:'operator&lt;&lt;' 不匹配(操作數類型是 'std::ostream {aka std::basic_ostream<char> }'和'列表')</char> 運算符重載時出錯(錯誤:“運算符&lt;&lt;”不匹配(操作數類型為“std::basic_ostream”)<char> &#39; 和 &#39;const 字符 [2]&#39;) 錯誤:'operator<<' 不匹配(操作數類型為'std::ostream {aka std::basic_ostream<char> }' 和 'std::ostream {aka std::basic_ostream<char> }')</char></char> 出現錯誤:'operator&lt;&lt;' 不匹配(操作數類型為 'std::basic_ostream<char> ' 和 'Complex') 盡管重載了 &lt;&lt; 運算符</char> 錯誤:'operator&lt;&lt;' 不匹配(操作數類型是 'std::ostream' {aka 'std::basic_ostream<char> '} 和 'std::_List_iterator<int> ')</int></char> 'operator&lt;&lt;' 不匹配(操作數類型是 'std::ostream {aka std::basic_ostream<char> }' 和 '分數')</char> 如何修復錯誤:'operator&lt;&lt;' 不匹配(操作數類型為 'std::ostream {aka std::basic_ostream<char> }' 和 'void')同時使用字符串和堆棧</char> 與&#39;operator &lt;&lt;&#39;不匹配(操作數類型為&#39;std :: ostream {aka std :: basic_ostream <char> }”
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM