I have an assignment where I am supposed to create a header file, a function.cpp file, and a main.cpp to create a gradebook for students where you can set and adjust data using vectors of objects. My code has no syntactical errors, but it is not running. My error message is:
"linker command failed with exit code 1 (use -v to see invocation)
13 duplicate symbols for architecture x86_64"
This is my first time posting so sorry about formatting issues. Thank you in advance...
void Student::findRecord(vector<Student> studentVector,string name, int studentSize, int SAFETY){
int h = 0;
while(h < studentSize ) {
// OUTPUT STUDENT INFO, ASK TO ADJUST
if (studentVector[h].getName() == name) {
cout << "Name Gender Math Prog";
cout << studentVector[h].getName() << " " << studentVector[h].getGender() << " " << studentVector[h].getMath() << " " << studentVector[h].getProg();
cout << "Select the following sub-options\n 1. Edit math score\n 2. Edit prog score " << SAFETY << endl;
int userChoice2;
switch(userChoice2) {
// ADJUST MATH SCORE
case 1:{
//Enter math score
cout << "Enter the new score: ";
cin >> math_score;
cout << endl;
cout << "Name Gender Math Prog";
cout << studentVector[h].getName() << " " << studentVector[h].getGender() << " " << studentVector[h].getMath() << " " << studentVector[h].getProg();
}
// ADJUST PROG SCORE
case 2:{
// Enter prog score
cout << "Enter the new score: ";
cin >> programming_score;
cout << endl;
cout << "Name Gender Math Prog";
cout << studentVector[h].getName() << " " << studentVector[h].getGender() << " " << studentVector[h].getMath() << " " << studentVector[h].getProg();
}
default:
cout << "You did not enter a valid input.\n" ;
} // end switch
} // end of if
else cout << "Name: " << name << " not found.";
break; // NAME NOT FOUND
}
}
//
// main.cpp
#include "StudentFunct.cpp"
int main() {
int studentSize; // number of students
cout << "How many students do you have?" << endl;
cin >> studentSize;
// SET RECORDS
string name;
char gender;
int math_score;
int programming_score;
Student *myStudent;
vector<Student> studentVector;
for( int s = 1; s <studentSize; s++){
cout << "Enter new student records (name gender math_score programming_score)" << endl;
cout << s << ": ";
cin >> name >> gender >> math_score >> programming_score;
myStudent->setRecord(name, gender, math_score, programming_score); // setRecord used here
studentVector.push_back(*myStudent);
} // SET RECORDS USED
// INTRO PRINT RECORDS or SELECT AND REPLACE
int SAFETY = 1;
int quitCount = 1;
int userChoice;
while (SAFETY > 0) {
cout << "Select the following options:\n";
cout << " 1. Print all student records\n";
cout << " 2. Search student record by name\n";
cout << " 3. Quit " << quitCount++ << endl;
if (quitCount == 100){
cout << "Maximum loops reached. Please run program again.";
break;
}
cin >> userChoice;
switch (userChoice) {
// PRINT RECORDS
case 1: { // print all
vector<Student>::iterator it;
for ( it = studentVector.begin(); it != studentVector.end(); ++it ) {
it->printRecords(); // printRecords used here
}
break;
} // PRINT RECORDS USED
// FIND STUDENT USING WHILE LOOP
case 2: {
cout << "Enter student name for searching: ";
cin >> name;