[英]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.