Below is an example implementation of the FoodItem class with the specified constructors in both the header file (FoodItem.h) and the source file (FoodItem.cpp).
#ifndef FOODITEM_H
#define FOODITEM_H
#include <string>
class FoodItem {
public:
// Default constructor
FoodItem();
// Parameterized constructor
FoodItem(const std::string& name, double fat, double carbohydrates, double protein);
// Other member functions if needed
private:
std::string name;
double gramsOfFat;
double gramsOfCarbohydrates;
double gramsOfProtein;
};
#endif // FOODITEM_H
Write a program that aligns with the information below
Nutritional information (classes/constructors) Given main(), complete the FoodItem class (in files Foodltem.h and Food item.cpp) with constructors to initialize each food item. The default constructor should initialize the name to "Water" and all other fields to 0.0. The second constructor should have four parameters (food name, grams of fat, grams of carbohydrates, and grams of protein) and should assign each class data member with the appropriate parameter value.