Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

What is the role of the Joint Commission in health care?

Answered: 1 week ago