功能标识符是未定义的C

Function identifier is undefined C++

本文关键字:未定义 标识符 功能      更新时间:2023-10-16

所以我在C 中写了一个函数,该功能是一个小数据库,其中包含两个类别,运动和饮食。这两个类非常相似,基本上是完全相似的。无论如何,我正在尝试打印运动课的内容。但是,我收到一条错误消息,即StoreDailyPlan不确定。这很有趣,因为两个课程都有自己的超载功能的版本,而且饮食版本正常。

void Wrapper::storeWeeklyPlan(ofstream& outfile, list<DietPlan>& dietlist)
{
DietPlan Node;
list<DietPlan>::iterator it; //this is our iterator, a pointer to the nodes in our list.
for(it = dietlist.begin(); it != dietlist.end(); it++) // start it at beginning, watch until end, and iterate it.
{
    Node = *it;
    storeDailyPlan(Node, outfile);
} //Another error here
}
void storeWeeklyPlan(ofstream& outfile, list<ExercisePlan>& exerciselist)
{
ExercisePlan Node;
list<ExercisePlan>::iterator it;
for (it = exerciselist.begin(); it != exerciselist.end(); it++)
{
    Node = *it;
    storeDailyPlan(Node, outfile); //THIS IS THE ERROR LINE
}
}
void Wrapper::storeDailyPlan(DietPlan diet, ofstream& outfile)
{
    outfile << diet;
}
void Wrapper::storeDailyPlan(ExercisePlan exercise, ofstream& outfile)
{
    outfile << exercise;
}

上面是将信息打印到文件上的4个函数。以下是其他一些相关代码。

class Wrapper
{
public:
Wrapper();
~Wrapper();
void runApp();
private:
int displayMenu();
void doChoice(int choice, list<DietPlan>& dietList, list<ExercisePlan>& exerciselist);
void loadDailyPlan(DietPlan& diet, ifstream& infile);
void loadDailyPlan(ExercisePlan& exercise, ifstream& infile);
void loadWeeklyPlan(ifstream& infile, list<DietPlan>& dietlist);
void loadWeeklyPlan(ifstream& infile, list<ExercisePlan>& exerciselist);
void storeWeeklyPlan(ofstream& outfile, list<DietPlan>& dietlist);
void storeWeeklyPlan(ofstream& outfile, list<ExercisePlan>& exerciselist);
void storeDailyPlan(DietPlan diet, ofstream& outfile);
void storeDailyPlan(ExercisePlan exercise, ofstream& outfile);

list <DietPlan> dietlist; //doubly linked list of DietPlan nodes. This is where it lives.
list <ExercisePlan> exerciselist;
};

如果您想查看任何其他代码,请告诉我。就像我说的那样,超载功能的饮食版本很好。

我得到的错误是标识符" StoredailyPlan"不确定,并且'StoreDailyPlan':找不到标识符

我正在使用Visual Studio2015。

您在storeWeeklyPlan的定义之前丢失了Wrapper::

storeWeeklyPlan的声明中有一个错字。

// Replace this
void storeWeeklyPlan(ofstream& outfile, list<ExercisePlan>& exerciselist)
// With this
void Wrapper::storeWeeklyPlan(ofstream& outfile, list<ExercisePlan>& exerciselist)