我想的Student
试图对象的数组传递给函数
数组传递到功能processStudent(string myFilename, Student* myArray, int &mySize)
时得到错误。 但它给了我不同的错误。
学生()什么也不做,但我想给它们分配某种价值,但它仍然给出确切的同样的错误信息:
在主我有这样的:
// 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
}
//在课堂上学生的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函数,因此它可以在读取文件时设置每个数组。
听起来像一个链接错误,你怎么建设? – Shep 2012-04-13 14:36:23