Question: In c++. Included is the code the new ReceiptBag class will be based off of. #pragma once #include #include vector.h template class Bag { public:

In c++. Included is the code the new ReceiptBag class will be based off of.

#pragma once

#include

#include "vector.h"

template

class Bag {

public:

void insert(Thing aThing) {

bagContents.push_back(aThing);

bagSize++;

}

Thing &pop() {

Thing aThing;

if (bagContents.size() > 0) {

aThing = bagContents[bagSize];

bagSize--;

}

else {

cout

}

return aThing;

}

int count(Thing aThing) {

int bagCount = 0;

for (int i = 0; i

if (bagCount[i] == aThing) {

bagCount++;

}

}

return bagCount;

}

private:

vector bagContents;

int bagSize = 0;

};

In c++. Included is the code the new ReceiptBag class will be

Suppose we want to be able to remove a specific item from a bag. So, when you put an item into a bag, also return some integer value you will use as a receipt. Modify the code for taking something out of the bag so that it looks for the item that matches that integer. Build a ReceiptBag class that implements this variation of a Bag data type. HINTS: - This is an application of the parallel arrays/vectors design that we discussed (and many of you hated) in CS318. - You will need to think about how to address what happens in the data structure(s) storing bag contents when someone removes an item. You can no longer assume you just peel an item from the start or end of that structure

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!