Question
Consider the following class definition: class Pizza { private: double diameter; int slices; double area() { return (diameter/2)*(diameter/2)*3.14; } public: bool sauce; bool cheese; bool
Consider the following class definition:
class Pizza {
private:
double diameter;
int slices;
double area() { return (diameter/2)*(diameter/2)*3.14; }
public:
bool sauce;
bool cheese;
bool pepperoni;
public:
Pizza(double dia,
int nslice=8,
bool has_sauce=true,
bool has_cheese=true,
bool has_pepp=true) {
diameter = dia;
slices = nslice;
sauce = has_sauce;
cheese = has_cheese;
pepperoni = has_pepp;
}
int getSlices() { return slices; }
double getDiameter() { return diameter; }
double areaPerSlice() {
return area() / slices;
}
};
Consider these variables declared within a function:
Pizza large(16, 10);
Pizza personal(6, 4,true,true,false);
Pizza medium(12);
Pizza small(10.0,6);
Evaluate the following expressions. Or, if the expression is illegal, explain why.
# | Expression | Evaluate or if illegal write Syntax error and explain why |
1 | large.getDiameter() | |
2 | small.getDiameter() | |
3 | large.areaPerSlice() > small.areaPerSlice() | |
4 | personal.pepperoni | |
5 | medium.getSlices() | |
6 | large.diameter | |
7 | large.sauce = true | |
8 | large.areaPerSlice() | |
9 | medium.slices | |
10 | personal.area() |
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