私は初心者で、ダイエットに役立つプログラムを楽しく書いています。このプログラムは完成していませんが、私が書いているようにコンパイルしています。タイトルに記載されているエラーが引き続き発生します。
クラスを含むアーキテクチャ x86_64 の未定義シンボル
同様の質問を見てきましたが、それらはすべてテンプレートと継承されたクラスに関係しており、私のシナリオとは異なります。私はクラスを宣言しているだけで、空想は何もありません。クラスが適切に定義されていないことに関係していると思いますが、それが何であるかわかりません。それは私が見逃しているばかげたものかもしれませんが、私はまだ立ち往生しています。ありがとう。
#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;
}