So I am writing a function in C++ that is a small database, containing two classes, exercise and diet. These two classes are very similar, basically exactly alike. Anyway I am trying to print the contents of my exercise class. However I am getting an error message that the function StoreDailyPlan is undefined. This is interesting because both classes have their own version of that overloaded function, and the diet version is working just fine.
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;
}
Above are the 4 functions directly responible for printing the information onto the file. Below is some other relevant code.
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;
};
Please let me know if you would like to see any other code. Like I said, the diet version of the overloaded function works just fine.
The Errors I get are identifier "storeDailyPlan" is undefined and 'storeDailyPlan': identifier not found
I am using Visual Studio 2015.