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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!