Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting Error when trying to pass an array of object to a function
    text
    copied!<p>I am trying to pass an array of <code>Student</code> </p> <p>into the function <code>processStudent(string myFilename, Student* myArray, int &amp;mySize)</code>. But it is giving me different kind of errors.</p> <p>The Student() does nothing, but I tried to assign them some sort of value, it still give the exact same error message:</p> <p>In the main I have this:</p> <pre><code>// 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); </code></pre> <p>The function is like this:</p> <pre><code>void processStudent(string myFilename, Student* myArray, int&amp; mySize) { // Something here, but removed still gives that error } </code></pre> <p>// In the class Student's cpp file</p> <pre><code>Student::Student() { // Nothing here } </code></pre> <p><strong>Error Message:</strong> </p> <pre><code>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 </code></pre> <p>I have been stripping and stripping down my code, but this error just won't go away. I want to create this array, and pass it to the processStudent function, so it can set up each one when reading the file.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload