daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. C   dynamic array cleared when object returned
  2. template <typename T>
  3. Bag<T> Bag<T>::operator+ (const Bag<T>& bag) {
  4.     int sizeofCurrentMultiset = cardinality_;
  5.     int sizeofPassedMultiset  = bag.cardinality_;
  6.     int totalSize = sizeofCurrentMultiset + sizeofPassedMultiset;
  7.  
  8.     Bag<T> newBag(totalSize);
  9.  
  10.     for (int i = 0; i < sizeofCurrentMultiset; i++) {
  11.         newBag.insert(array_[i]);
  12.     }
  13.  
  14.     for (int i = 0; i < sizeofPassedMultiset; i++) {
  15.         newBag.insert(bag.array_[i]);
  16.     }
  17.  
  18.     return newBag;
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top