103k views
0 votes
24.2 Online shopping cart (Part 2)

This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program).

(1) Extend the ItemToPurchase struct to contain a new data member. (2 pt)

char itemDescription[ ] - set to "none" in MakeItemBlank()
Implement the following related functions for the ItemToPurchase struct.

PrintItemDescription()
Has an ItemToPurchase parameter.

User Jgiles
by
7.7k points

1 Answer

1 vote

Answer:

It seems like you are working on a C++ program that extends the earlier "Online shopping cart" program and you want to extend the `ItemToPurchase` struct to contain a new data member `char itemDescription[]` which is set to "none" in `MakeItemBlank()` function and implement the following related functions for the `ItemToPurchase` struct:

- `PrintItemDescription()`: Has an ItemToPurchase parameter.

Here's an example of how you can extend the `ItemToPurchase` struct:

```c++

struct ItemToPurchase {

string itemName;

int itemPrice;

int itemQuantity;

string itemDescription;

};

void MakeItemBlank(ItemToPurchase* item) {

item->itemName = "none";

item->itemPrice = 0;

item->itemQuantity = 0;

item->itemDescription = "none";

}

void PrintItemDescription(ItemToPurchase item) {

cout << item.itemName << ": " << item.itemDescription << endl;

}

```

Step-by-step explanation:

User Jeff Nyak
by
8.5k points