#include<iostream>
using namespace std;
#include<string>
#include<new>
class student {
public:
student(int, int);
void disp();
private:
int no, num;
static int sum;
static int count;
};
int student::count =0;
int student::sum =0;
student::student (int n, int nu)
{
no=n;
num=nu;
sum+=num;
count++;
}
void student::disp ()
{
cout<<"There are "<<count<< " student(s)"<<endl
<<"语文总分: "<<sum<<endl;
}
int main ()
{
int no, num, i;
for(i=1; i<=10; i++) {
cout<<"请输入学号,语文成绩"<<endl;
cin>>no>>num;
student *f=new student(no,num);
}
f->disp (); // error C2065: 'f' : undeclared identifier
// error C2227: left of '->disp' must point to class/struct/union
return 0;
}
编译出错,请问如何解决?谢谢