```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;
}
报错的是主函数里面每行输出函数里面的,第二个“<<”符号
```
当然出错啦,静态成员函数dis返回值是void!
系统提供的左移运算符,只能用于内置变量,常量等,若要对于自定义变量(结构体,类等)使用,需重载运算符<<
求关注,新人C/C++博主
dis()是静态函数,不能通过对象调用,stud_A.dis ()写法不对。