Consider the class as partially defined here:
//class PizzaOrder
class PizzaOrder...
![subject](/tpl/images/cats/informatica.png)
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](/tpl/images/cats/User.png)
Answers: 3
Another question on Computers and Technology
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 15:30
Whats are the different parts of no verbal comunication, especially body language?
Answers: 3
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 07:00
What are three software programs for mobile computing?
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 14:30
Select the correct answer. what does it indicate when a website displays https instead of http? a. the website is secure. b. there is no secure sockets layer. c. the secure sockets layer is hidden. d. the website is not secure.
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 15:00
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a.an advanced knowledge of physics and math b.an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 1
You know the right answer?
Questions
![question](/tpl/images/cats/biologiya.png)
Biology, 25.06.2019 04:00
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/geografiya.png)
Geography, 25.06.2019 04:00
![question](/tpl/images/cats/biologiya.png)
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 25.06.2019 04:00
![question](/tpl/images/cats/fr.png)
![question](/tpl/images/cats/biologiya.png)
Biology, 25.06.2019 04:00
![question](/tpl/images/cats/obshestvoznanie.png)
Social Studies, 25.06.2019 04:00
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 25.06.2019 04:00
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/istoriya.png)
History, 25.06.2019 04:00
![question](/tpl/images/cats/es.png)
Spanish, 25.06.2019 04:00
![question](/tpl/images/cats/himiya.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/istoriya.png)