我有以下结构:
template <class T>
struct Array{
int lenght;
T * M;
Array( int size ) : lenght(size), M(new T[size])
{
}
~Array()
{
delete[] M;
}
};
和类(将填充结构的对象):
class Student{
private:
int ID;
int group;
char name[];
public:
Student();
~Student();
void setStudent(int,int,char){
}
char getName(){
return *name;
}
void getGroup(){
}
void getID(){
}
};
现在,当我想初始化 Array 类型时,我在 Main.cpp 中得到以下内容:
#include <iostream>
#include "Domain.h"
#include "Student.h"
//#include ""
using namespace std;
int main(){
cout<<"start:"<<endl<<endl;
Array <Student> DB(50);
Array <Student> BU(50);
return 0;
}
错误:
g++ -o Lab6-8.exe UI.o Repository.o Main.o Domain.o Controller.o
Main.o: In function `Array':
D:\c++\Begin\Lab6-8\Debug/..//Domain.h:16: undefined reference to `Student::Student()'
D:\c++\Begin\Lab6-8\Debug/..//Domain.h:16: undefined reference to `Student::~Student()'
Main.o: In function `~Array':
D:\c++\Begin\Lab6-8\Debug/..//Domain.h:21: undefined reference to `Student::~Student()'
知道为什么吗?