Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8878715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:46:48+00:00 2026-06-14T19:46:48+00:00

I am a beginner and writing a program for fun that helps me diet.

  • 0

I am a beginner and writing a program for fun that helps me diet. This program isn’t done but compiling as I write. I keep getting the error mentioned in the title:

Undefined symbols for architecture x86_64 with classes

I’ve looked at similar questions but they all have to do with templates and inherited classes which is different than my scenario. I’m just declaring a class, nothing fancy. I think it has to do with the class not being defined properly but I can’t figure out what it is. It might be something dumb I’m missing 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;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:46:49+00:00Added an answer on June 14, 2026 at 7:46 pm

    There is no constructor for class Meal. You can solve it e.g. like this:

    class Meal
    {
    private:
      string m_name;
      int m_protein;
      int m_carbs;
      int m_fat;
      int m_calories;
    
    public:
      Meal(string name, int calories, int protein, int carbs, int fat)
        : m_name(name), m_protein(protein),
          m_carbs(carbs), m_fat(fat), m_calories(calories)
      {
      }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just a beginner in C++. I'm writing small and simple program that prints
Rank beginner here please be gentle... I'm writing a program in perl that finds
I'm beginner to c++ and writing a program that accepts user choices and acts
I am beginner when it comes to writing makefiles but I am having this
I'm a beginner in Java and I'm writing a program to read from multiple
i am writing javascript code on nodepad++,i am at beginner level and write just
I am beginner in the field of hash. I am writing a program to
I was writing this small script the other day.It is a small program which
This may be a total beginner's question, but I have yet to find an
I am a beginner in Android, and I am writing a short program to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.