(Solved):Design a program that declares two Pizza objects and then sets and displays their values. View Answer…

 

Question

Design a program that declares two Pizza objects and then sets and displays their values.

 

EXPERT ANSWER

Refer C++ program given below for the solution.

#include <iostream>
#include<string>
using namespace std;
class Pizza {
  
private:
int diameter; // in inches
string toppings; // cheese / pepperoni etc
float price;
public:
Pizza(int dia,float cost)
{
    diameter = dia;
    toppings = "";
    price = cost;
}
// set functions
void setDiameter(int dia)
{
     diameter = dia;
}
void setToppings(string top)
{
      toppings = top;
}
void setPrice(float cost)
{
      price = cost;
}
//

Scroll to top