I start and write a program for pleasure that helps me diet. This program does not run, but compiles on recording. I keep getting the error mentioned in the title:
Undefined characters for x86_64 architecture with classes
I looked at similar questions, but they all relate to templates and inherited classes that are different from my scenario. I just declare a class, nothing out of the ordinary. I think this is due to the fact that the class is not defined properly, but I cannot understand what it is. It might be something stupid that I'm missing out on, but I'm still stuck. Thanks.
#include <iostream> #include <string> using namespace std; class Meal { private: string name; int protein; int carbs; int fat; int calories; public: Meal(string name, int calories, int protein, int carbs, int fat); }; int main() { int calories = 0; int rest_or_lift; int create_or_not; cout << "Enter 1 if it is a workout day, enter 2 if it is a rest day./n"; cin >> rest_or_lift; if (rest_or_lift == 1) { calories = 2554; } else if (rest_or_lift == 2) { calories = 1703; } cout << "Enter 1 to input existing foods, enter 2 to create new foods./n"; cin >> create_or_not; if (create_or_not == 1) { cout << "This aspect has not yet been created /n"; //need to fix this part } else if (create_or_not == 2) { do { string name; int protein; int carbs; int fat; int calories; cout << "Enter the name of the food./n"; cin >> name; cout << "Enter how many calories the food has. /n"; cin >> calories; cout << "Enter how many grams of protein the food has /n"; cin >> protein; cout << "Enter how many grams of carbs the food has /n"; cin >> carbs; cout << "Enter how many grams of fats the food has /n"; cin >> fat; Meal(name, calories, protein, carbs, fat); cout << "Enter another food? Enter 1 to exit, 2 to continue."; cin >> create_or_not; } while (create_or_not == 2); } return 0; }
source share