Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PIZZA.CPP : /**************************************************************************** Implentation file for pizza class ****************************************************************************/ #include using namespace std; #include pizza.h // The preferred ctor is the only member function which
PIZZA.CPP :
/**************************************************************************** Implentation file for pizza class ****************************************************************************/ #includeusing namespace std; #include "pizza.h" // The preferred ctor is the only member function which needs to // be implemented in this file. pizza::pizza( const string custName, // preferred ctor const pizzaSize size, const toppings top1, const toppings top2, const toppings top3 ) { m_customerName = custName; m_size = size; m_toppings[0] = top1; m_toppings[1] = top2; m_toppings[2] = top3; }
PIZZA.h
#ifndef PIZZA_H #define PIZZA_H enum pizzaSize { small, medium, large }; enum toppings { none, // used when less than 3 toppings requested cheeseOnly, pepperoni, meatball, sausage, pepperAndOnions, everything }; class pizza { public: virtual ~pizza(void) {} // dtor - notice that the dtor is actually // implemented here, since no class members // are dynamically allocated. pizza(const string custName, // preferred ctor const pizzaSize size, const toppings top1, const toppings top2, const toppings top3 ); // Accessor Functions string getCustName(void) const { return m_customerName; } pizzaSize getSize(void) const { return m_size; } toppings getFirstTopping(void) const { return m_toppings[0]; } toppings getSecondTopping(void) const { return m_toppings[1]; } toppings getThirdTopping(void) const { return m_toppings[2]; } private: // Data members of the class string m_customerName; pizzaSize m_size; toppings m_toppings[3]; // The unused OCF functions are private AND unimplemented. This will insure they will not be used. pizza(void); // default ctor pizza(const pizza& src); // copy ctor pizza& operator=(const pizza& src); // assignment operator }; #endif
C++ Programming Exercise A restauranteur has hired you to write a program to keep track of his pizza orders. You are given the following pizza class files to use: 1. pizza.h pizza.cpp Write a CPP program that allows the restauranteur to keep track of 4 pizzas using dynamic allocation, i.e. new and delete, to store them. (hint -just start with 1.) The restauranteur will use iostreams to type in the customer's order, and then create the pizza object using the preferred ctor. Immediately after creating the pizza object, the system will output the 5 data fields of the pizza object. You'll need to use the pointer operator>) to accomplish this. 2. 3. The pizza class files do compile - you should not need to modify them at all. C++ Programming Exercise A restauranteur has hired you to write a program to keep track of his pizza orders. You are given the following pizza class files to use: 1. pizza.h pizza.cpp Write a CPP program that allows the restauranteur to keep track of 4 pizzas using dynamic allocation, i.e. new and delete, to store them. (hint -just start with 1.) The restauranteur will use iostreams to type in the customer's order, and then create the pizza object using the preferred ctor. Immediately after creating the pizza object, the system will output the 5 data fields of the pizza object. You'll need to use the pointer operator>) to accomplish this. 2. 3. The pizza class files do compile - you should not need to modify them at all
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started