Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- C dynamic array cleared when object returned
- template <typename T>
- Bag<T> Bag<T>::operator+ (const Bag<T>& bag) {
- int sizeofCurrentMultiset = cardinality_;
- int sizeofPassedMultiset = bag.cardinality_;
- int totalSize = sizeofCurrentMultiset + sizeofPassedMultiset;
- Bag<T> newBag(totalSize);
- for (int i = 0; i < sizeofCurrentMultiset; i++) {
- newBag.insert(array_[i]);
- }
- for (int i = 0; i < sizeofPassedMultiset; i++) {
- newBag.insert(bag.array_[i]);
- }
- return newBag;
- }
Add Comment
Please, Sign In to add comment