Question: (12 points) Write the two constructors bag(size_type initial) and bag(const bag& source) (each has 5 points) and the destructor-bag) (2 points) for the bag class

 (12 points) Write the two constructors bag(size_type initial) and bag(const bag&

(12 points) Write the two constructors bag(size_type initial) and bag(const bag& source) (each has 5 points) and the destructor-bag) (2 points) for the bag class as follows. You are allowed to use the C++standard library copy function copylsource.data, source.data used, data) (described in page 116 in our textbook). 4. class bag public: I TYPEDEFS and MEMBER CONSTANTS typedef int value type; typedef std::size t size type; static const size type DEFAULT_CAPACITY 3; CONSTRUCTORS and DESTRUCTOR bag(size type initial_capacityDEFAULT_CAPACITY); bag(const bag& source); -bag) private: value type data; I/ Pointer to partially filled dynamic array size type used; // How much of array is being used size type capacity; II Current capacity of the bag bag::bag(size type initial capacityDEFAULT_CAPACITY) /* Postcondition: The bag is empty with an initial capacity given by the paraneter. / bag::bag(const bag& source) * Postcondition: The bag that is being constructed has been initialized with the same items and capacity as source. / bag::-bagO Postcondition: The dynanic memory has been returned to the heap What output is produced by the following? // address of i is 900 int *int_ptr, i; i -30; cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The image you provided contains a C code snippet along with a description of the class bag and a specific question that asks for writing constructors ... View full answer

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!