这个错误怎么改啊?帮帮忙啊,各位!
#define N 20class student
{
private:char name[20];
float score;
public:
student();
void display();
float Get();
};
template<class T>
class array
{
private:T s[N];
public:T GetArray(T *p);
void set();
float GetAverage();
};
#include"student.h"
#include<iostream>
using namespace std;
student::student()
{
cout<<"请输入学生的姓名:"<<endl;
cin>>name;
cout<<"请输入学生的成绩:"<<endl;
cin>>score;
}
float student::Get()
{
return score;
}
void student::display()
{
cout<<"姓名:"<<name<<" 成绩:"<<score<<endl;
}
template<class T>
T array<T>::GetArray(T *p)
{
for(int i=0;i<N;i++)
{
&array[i]=p;
}
return s[i].Get();
}
template<class T>
float array<T>::GetAverage()
{
float sum=0;
for(int i=0;i<N;i++)
{
sum+=s[i].Get();
}
return sum/N;
}
#include"student.h"
#include<iostream>
#include<cmath>
using namespace std;
#define N 20
int main()
{
student a[N];
array<student> b;
b.GetArray(a);
cout<<b.GetAverage()<<endl;
}
-------------------Configuration: student - Win32 Debug--------------------
Linking...
test.obj : error LNK2001: unresolved external symbol "public: float __thiscall array<class student>::GetAverage(void)" (?GetAverage@?$array@Vstudent@@@@QAEMXZ)
test.obj : error LNK2001: unresolved external symbol "public: class student __thiscall array<class student>::GetArray(class student *)" (?GetArray@?$array@Vstudent@@@@QAE?AVstudent@@PAV2@@Z)
Debug/student.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
student.exe - 3 error(s), 0 warning(s)