Question: Question 5 ( 1 0 points ) Consider writing a client function ( non - member function ) that creates and returns a new ADT
Question points
Consider writing a client function nonmember function that creates and returns a new ADT Bag object that contains all items from a given Bag object without duplicated items. The function is not allowed to modify the given Bag object. Which of the following implementations for this function is correct?
Question options:
a
Template
void bagCopyBag& aBag
int size aBag. getCurrentSize;
forint i; i
aBag.removeitemsi;
return aBag;
b
Template
void bagCopyBag aBag
int size aBag. getCurrentSize;
forint i; i
Bag bagCopyconst Bag& aBag
vector items aBag.toVector;
Bag newBag;
int size items.size;
forint i; i
Bag bagCopyconst Bag& aBag
int size aBag. getCurrentSize;
ItemType ItemsCopysize;
ItemsCopyitems;
bool duplicated;
forint i; i
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
