简体   繁体   English

尝试在数据库管理系统中调用 function 时出现未定义的引用错误以及退出状态错误

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

So I am trying to call a function which creates an assessment class object within the newStudent function.所以我试图调用一个 function 来创建一个评估 class object 在 newStudent ZC1C425268E68394FCAB11 Ideallly the aim is for the newStudent function to run and after it reaches level selection it would call the respective makeAssess functions.理想情况下,目标是让 newStudent function 运行,并在达到级别选择后调用相应的 makeAssess 函数。 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.然后每个 makeAssess 函数将递归调用自己,直到每个级别的总权重为 100,然后移动到下一个 makeAssess function。 All the makeAssess functions were already defined at the start of the program.所有的 makeAssess 函数都已经在程序开始时定义了。

Edit: Iam using CodeBlocks with a GNU GCC compiler.编辑:我将 CodeBlocks 与 GNU GCC 编译器一起使用。 The two errors are "|undefined reference to `makeassessH()'|"这两个错误是“|未定义对`makeassessH()'的引用|” and "|error: ld returned 1 exit status|"和“|错误:ld 返回 1 个退出状态|”

MPE: 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;
}

The error message is telling you (and us all now) that you have declared a function named错误消息告诉您(现在我们所有人)您已经声明了一个名为 function

void makeassessH()

but you never defined it.但你从未定义它。 You do have a function named确实有一个名为 function

void makeassesH()

but that's not the same spelling.但这不是同一个拼写。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 编译问题:在函数“_start”中:未定义对“main” collect2 的引用:错误:ld 返回 1 个退出状态 - Compiling problem : In function `_start': undefined reference to `main' collect2: error: ld returned 1 exit status 对 WinMain 的未定义引用,[错误] Id 返回 1 个退出状态 - undefined reference to WinMain, [Error] Id returned 1 exit status C++ 中的编译错误:对“main”collect2 的未定义引用:错误:ld 返回 1 个退出状态 - Compilation Error in C++: undefined reference to `main' collect2: error: ld returned 1 exit status 错误:尝试在全新的系统安装中构建应用程序后,未定义对“ ...”的引用 - Error: undefined reference to '…' after trying to build app in fresh system installation 对 `print(char const (*) [80], int, int)&#39; collect2 的未定义引用:错误:ld 返回 1 个退出状态 - undefined reference to `print(char const (*) [80], int, int)' collect2: error: ld returned 1 exit status 尝试实现抽象类时出现未定义的引用错误 - undefined reference error when trying to implement abstract class Zenlib错误:对使用typedef的Open函数调用的未定义引用 - Zenlib error : undefined reference to Open function call which uses typedef 功能上的“ [错误] ld返回了1个退出状态” - “[Error] ld returned 1 exit status” on function 尝试在main中调用函数时出错。 - Error when trying to call a function in main. 错误:在另一个成员函数中调用成员函数时未定义对…的引用 - Error:undefined reference to… when calling a member function in another member function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM