c++ 不明白我在roster.cpp文件和student.cpp文件中的代码中的一些错误[已关闭]

idfiyjo8  于 2023-04-08  发布在  其他
关注(0)|答案(1)|浏览(92)

**已关闭。**此问题需要debugging details。当前不接受答案。

编辑问题以包括desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
19小时前关闭
Improve this question
roster.cpp中的错误:
“Roster::parse”的行外定义的返回类型与声明中的返回类型不同
预期语句
student.cpp中的错误:
“getDegreeProgram”的行外定义与“Student”中的任何声明都不匹配
函数声明符后应为函数体
我尝试在roster.h中修复parse,但它不起作用。我找不到roster.cpp中多余或丢失的花括号。
我对getDegreeProgram的错误感到困惑。
这里是链接:https://github.com/peonybliss/Class-Roster.git

kqqjbcuj

kqqjbcuj1#

这很简单,roster.cpp中的函数与roster.h中声明的任何函数都不匹配
在roster.h中,您有此

Student* parse(string studentData);
void add (string studentID,string firstName,string lastName, string email, int age, int daysInCourse1, int daysInCourse2, int daysInCourse3, DegreeProgram degreeprogram);

但是在roster.cpp中你有这个

// Add a new student to the class roster
void Roster::parse(string studentData)

这不仅与roster.h中的任何内容都不匹配,而且实际上是您在roster.cpp中定义的parse的第二个版本
student.cpp文件以以下代码结束

void Student::print()

编译器告诉你,它希望你在这里定义一个函数,比如

void Student::print()
{
     // some code here
}

当你成为一名程序员时,你会发现关注细节是一项至关重要的技能,这两个错误都不难理解,只是很难发现。

相关问题