subject
Computers and Technology, 03.04.2020 16:39 grinch4

Consider the class as partially defined here:

//class PizzaOrder
class PizzaOrder
{
public:
static const int MAX_TOPPINGS = 20;

private:
// instance members
string toppings[MAX_TOPPINGS];
int numToppings;

// constructor
public PizzaOrder();

// accessor tells # toppings on pizza, i. e., # toppings in array
int getNumToppings() { return numToppings; }

// etc.
}

PizzaOrder::PizzaOrder()
{
numToppings = 0;
}
We want to write an instance method, addTopping() that will take a string parameter, topping, and add it to the toppings[] array at the next available location as determined by the int member numToppings. Assume any string passed in is valid and no other method modifies the toppings[] array or numToppings.

The client would call it like so:

somePizzaOrder. addTopping( "onions" );
Which is a correct definition for addTopping() based on what you see, above?

A. bool PizzaOrder::addTopping( string topping )
{
numToppings++;
if ( numToppings >= MAX_TOPPINGS )
return false;
toppings[numToppings] = topping;
return true;
}
B. void PizzaOrder::addTopping( string topping )
{
toppings[numToppings] = topping;
}
C. bool PizzaOrder::addTopping( string topping )
{
if ( numToppings >= MAX_TOPPINGS || numToppings < 0 )
return false;
toppings[numToppings++] = topping;
return true;
}
D. void PizzaOrder::addTopping( string topping )
{
toppings[numToppings++] = topping;
}
E. bool PizzaOrder::addTopping( string topping )
{
if ( numToppings >= MAX_TOPPINGS )
return false;
toppings[numToppings++] = topping;
return true;
}
F. bool PizzaOrder::addTopping( string topping )
{
if (numToppings > MAX_TOPPINGS)
return false;
toppings[numToppings++] = topping;
return true;
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:10
3. bob is arguing that if you use output feedback (ofb) mode twice in a row to encrypt a long message, m, using the same key each time, it will be more secure. explain why bob is wrong, no matter what encryption algorithm he is using for block encryption (15 points).
Answers: 3
question
Computers and Technology, 23.06.2019 01:30
For a typical middle-income family, what is the estimated cost of raising a child to the age of 18? $145,500 $245,340 $304,340 $455,500
Answers: 2
question
Computers and Technology, 23.06.2019 11:00
In the context of the box model, what is the difference between a margin and a padding? a. a padding lies outside a box border, while a margin lies inside it. b. a padding lies inside a box border, while a margin lies outside it. c. a padding can be adjusted independently, while a margin depends on the size of its box. d. a padding depends on the size of its box, while a margin can be adjusted independently.
Answers: 3
question
Computers and Technology, 23.06.2019 14:30
Which of the following would not be considered a pc? a. mainframe b. desktop c. tablet pc d. laptop
Answers: 2
You know the right answer?
Consider the class as partially defined here:

//class PizzaOrder
class PizzaOrder...
Questions
question
Mathematics, 10.10.2019 22:00
Questions on the website: 13722363