新人学C++,不知道哪出错了,请大侠帮忙
#include<iostream>using namespace std;
class Student
{
public:
Student(int n,float s):num(n),score(s){}
void display();
void change(int m,float n);
private:
int num;
float score;
};
void Student::display()
{
cout<<num<<" "<<score<<endl;
}
void Student::change(int m,float n)
{
num=m;
score=n;
}
int main()
{
Student stu1(1,90);
stu1.display();
Stu1.change(2,80);
Stu1.display();
return 0;
}
编译结果:
D:\新建文件夹\9\4.cpp(26) : error C2065: 'Stu1' : undeclared identifier
D:\新建文件夹\9\4.cpp(26) : error C2228: left of '.change' must have class/struct/union type
D:\新建文件夹\9\4.cpp(27) : error C2228: left of '.display' must have class/struct/union type