Zookal
Zookal

We’d love to hear any feedback or comment from you!

© 2011-2021 Zookal Pty Ltd

View question and answer

From our collection of questions and answers
Engineering · Computer Science
Question details

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()

Answer
Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.

Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.