silence_sz 2022-04-12 02:04 采纳率: 100%
浏览 30
已结题

最后报错,没有与“<<”所匹配的操作符

问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果

```c++
#include<iostream>
#include<string>
using namespace std;
class croster
{
    static int count;
private:
    string name;
    int Math;
    int English;
    int Sum;
public:
    croster(string na = "undef", int m = 100, int e = 100);
    void display();
    int cumulation();
    static void dis()
    {
        cout << "count" << endl;
    }
};
int croster::count = 100;
croster::croster(string na, int m, int e):name(na),Math(m),English(e)
{
    cout << "Welcome new class." << endl;
    Sum = Math + English;
    count--;
}
void croster::display()
{
    cout << name << endl;
    cout << "Math:" << Math << endl;
    cout << "English:" << English << endl;
    cout << "Sum:" << Sum << endl;
}
int croster::cumulation()
{
    Sum = Math + English;
    return Sum;
}
int main()
{
    cout << "Number of all student=" << croster::dis() << endl;
    croster list[3];
    cout << "Number of all student=" << list[1].dis ()<< endl;
    croster stu_A;
    cout << "Number of all student=" << stu_A.dis ()<< endl;
    cout << "Number of all student=" << croster::dis() << endl;
    return 0;
}
报错的是主函数里面每行输出函数里面的,第二个“<<”符号




```

  • 写回答

3条回答 默认 最新

  • czy1219 2022-04-12 07:08
    关注

    当然出错啦,静态成员函数dis返回值是void!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 11月29日
  • 已采纳回答 11月21日
  • 创建了问题 4月12日

悬赏问题

  • ¥50 关于#华为#的问题:华为HMS账号登录
  • ¥20 Html备忘录页面制作
  • ¥15 黄永刚的晶体塑性子程序中输入的材料参数里的晶体取向参数是什么形式的?
  • ¥20 数学建模来解决我这个问题
  • ¥15 计算机网络ip分片偏移量计算头部是-20还是-40呀
  • ¥15 stc15f2k60s2单片机关于流水灯,时钟,定时器,矩阵键盘等方面的综合问题
  • ¥15 YOLOv8已有一个初步的检测模型,想利用这个模型对新的图片进行自动标注,生成labellmg可以识别的数据,再手动修改。如何操作?
  • ¥30 NIRfast软件使用指导
  • ¥20 matlab仿真问题,求功率谱密度
  • ¥15 求micropython modbus-RTU 从机的代码或库?