C++类涵数调用``出错`?
#include <iostream>#include <string>
using namespace std;
class Student
{
private:
int number;
float score1,score2,score3;
char *name;
public:
Student();
void get(int ,char *,float ,float ,float);
float aver();
void show();
~Student();
};
void Student::get(int numbers,char *names,float score1s,float score2s,float score3s)
{
number=numbers;
name=names;
score1=score1s;
score2=score2s;
score3=score3s;
}
float Student::aver()
{
return ((score1+score2+score3)/3);
}
void Student::show()
{
cout<<"学号:"<<number<<"姓名:"<<name<<"语文:"<<score1<<"数学:"<<score2
<<"英语:"<<score3<<"平均分:"<<aver()<<endl;
}
void main()
{
int i,j;
Student s[3];
Student temp;
s[0].get(1,"张三",90,88,89);
s[1].get(2,"李四",99,90,95);
s[2].get(3,"王五",78,80,69);
for(i=0;i<3;i++)
for(j=0;j<2;j++)
if(s[j].aver()<s[j+1].aver())
{temp=s[j];s[j]=s[j+1];s[j+1]=temp;}
cout<<"按平均分从高到低排列"<<endl;
s[0].show();
s[1].show();
s[2].show();
}
执行的时候出错`编译不出错``
Linking...
class.obj : error LNK2001: unresolved external symbol "public: __thiscall Student::Student(void)" (??0Student@@QAE@XZ)
class.obj : error LNK2001: unresolved external symbol "public: __thiscall Student::~Student(void)" (??1Student@@QAE@XZ)
Debug/class.exe : fatal error LNK1120: 2 unresolved externals
执行 link.exe 时出错.
class.exe - 1 error(s), 0 warning(s)