我正在尝试传递一个数组Student
进入函数processStudent(string myFilename, Student* myArray, int &mySize)
。但它给了我不同类型的错误。
Student() 什么都不做,但我尝试为它们分配某种值,它仍然给出完全相同的错误消息:
主要我有这个:
// Create an array of students, with the size of theMax (256)
Student* arrayOfStudent= new Student[theMax];
// An integer that will keep track of actually how many students
// Because when we loop, we want to loop within the cell
// that actually have data or student.
int actualSize = 0;
// Invoke the helper function to set up the array of students
// It passed the arryOfStudent by reference, so the changes
// inside of the function will be reflected when it returns
processStudent(filename, arrayOfStudent, actualSize);
函数是这样的:
void processStudent(string myFilename, Student* myArray, int& mySize)
{
// Something here, but removed still gives that error
}
// 在班级Student的cpp文件中
Student::Student()
{
// Nothing here
}
错误信息:
new-host-2:csci135p1 george$ g++ -Wall -o csci135p2main csci135p2main.cpp
Undefined symbols for architecture x86_64:
"Student::Student()", referenced from:
_main in cc3fTXti.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
我一直在剥离和剥离我的代码,但这个错误不会消失。我想创建这个数组,并将它传递给 processStudent 函数,这样它就可以在读取文件时设置每一个。