我想的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