Undefined reference error along with exit status error when trying to call function in database management system

56 Views Asked by At

So I am trying to call a function which creates an assessment class object within the newStudent function. Ideallly the aim is for the newStudent function to run and after it reaches level selection it would call the respective makeAssess functions. Each of the makeAssess functions would then recursively call themselves until the total weighting of each level is 100 and then move onto the next makeAssess function. All the makeAssess functions were already defined at the start of the program.

Edit: Iam using CodeBlocks with a GNU GCC compiler. The two errors are "|undefined reference to `makeassessH()'|" and "|error: ld returned 1 exit status|"

MPE:

//Relevant libraries
#include <iostream>
#include <fstream>

using namespace std;

int option;

void newStudent();
void makeassessH();
void makeassessI();
void makeassessC();

class Student {
public:
    int stuNum;

    std::string stuName;

    int startDate;

    int endDate;

    string progofStudy;

    char level;
};

class Assessment{
public:
    std::string title;

    int weight;

    double grade;

    string deadline;
};

int main()
{
//The option page
while (option != 5) {
    cout << "\nPlease choose an option\n"
    "1. Add new students\n"
    "2. Student Login\n"
    "3. Staff Login\n"
    "4. Admin View\n"
    "5. Exit\n"
    "Enter option: ";

    cin >> option;

    if (option == 1) {
        newStudent();

    } else if (option == 5)
           return 0;

    }
}


void newStudent() {
    Student stu;
        string studentName = stu.stuName;

        cout << "Please enter in your student number: ";
        cin >> stu.stuNum;

        cout << "Please enter in your name: ";
        cin.ignore();
        getline (cin, studentName);

        cout << "Please enter in your start date: ";
        cin >> stu.startDate;

        cout << "Please enter in your end date: ";
        cin >> stu.endDate;

        cout << "Please enter in your programme of study: ";
        cin.ignore();
        getline(cin, stu.progofStudy);

        cout << "Please enter your level of study: ";
        cin >> stu.level;

        if(stu.level == toupper('h')){
            makeassessH();
            makeassessI();
            makeassessC();
        }else if (stu.level == toupper('i')){
            makeassessI();
            makeassessC();

        }else if(stu.level == toupper('c')) {
            makeassessC();
        }
}

void makeassesH(){
    Assessment assessmentH;

    cout << "Assessment title: ";
    cin.ignore();
    getline (cin, assessmentH.title);

    cout << "Assessment weighting: ";
    cin >> assessmentH.weight;

    cout << "Assessment grade: ";
    cin >> assessmentH.grade;

    cout << "Assessment deadline: ";
    cin >> assessmentH.deadline;

}

void makeassessI(){
    Assessment assessmentI;

    cout << "Assessment title: ";
    cin.ignore();
    getline (cin, assessmentI.title);

    cout << "Assessment weighting: ";
    cin >> assessmentI.weight;

    cout << "Assessment grade: ";
    cin >> assessmentI.grade;

    cout << "Assessment deadline: ";
    cin >> assessmentI.deadline;
}
void makeassessC(){
    Assessment assessmentC;

    cout << "Assessment title: ";
    cin.ignore();
    getline (cin, assessmentC.title);

    cout << "Assessment weighting: ";
    cin >> assessmentC.weight;

    cout << "Assessment grade: ";
    cin >> assessmentC.grade;

    cout << "Assessment deadline: ";
    cin >> assessmentC.deadline;

    int totalWeight = totalWeight + assessmentC.grade;
}
1

There are 1 best solutions below

0
Drew Dormann On

The error message is telling you (and us all now) that you have declared a function named

void makeassessH()

but you never defined it. You do have a function named

void makeassesH()

but that's not the same spelling.