去掉const可以运行……加上const意味着指针指向不能改变
#include
using namespace std;
class Student
{
public:
Student(int n,float s):num(n),score(s){}
void change(int n,float s){num=n;score=s;}
void display(){};//{cout<
int num;
float score;
};
int main()
{
Student stud(101,78.5);
Student *p=&stud;//这里是题要求的
p->display();
p->change(101,80.5);
p->display();
return 0;
}