#include #include using namespace std; struct inventory_item { string name; int number; double cost; int num_in_inventory; }; void print_item(const inventory_item item); bool sell_item(inventory_item & to_sell); void main() { //create a new inventory_item and //set its values inventory_item shirts; shirts.name = "Shirts"; shirts.number = 1232; shirts.cost = 20.00; shirts.num_in_inventory = 10; //print the new item print_item(shirts); //sell one of the new item sell_item(shirts); //print the item again print_item(shirts); //create an array of inventory_items inventory_item items[2]; items[0].name = "Hats"; items[0].number = 1234; items[0].cost = 6.99; items[0].num_in_inventory = 15; items[1].name = "Jackets"; items[1].number = 1235; items[1].cost = 59.99; items[1].num_in_inventory = 20; print_item(items[0]); sell_item(items[0]); print_item(items[0]); } /* A function to print all info about an item. input - the item to print output - none */ void print_item(const inventory_item item) { cout << "Item: " << item.name << endl; cout << "Item Number: " << item.number << endl; cout << "Cost: " << item.cost << endl; cout << "Number Remaining: " << item.num_in_inventory << endl; } /* A function to sell an item by reducing the number in the inventory by 1. input - reference to an inventory_item output - true if item was sold, false otherwise What would happen if you left off the &? What would happen if you added const? */ bool sell_item(inventory_item & to_sell) { bool sell_ok = false; if(to_sell.num_in_inventory > 0) { to_sell.num_in_inventory = to_sell.num_in_inventory - 1; sell_ok = true; } else { sell_ok = false; } return sell_ok; }