Question: In the assignment you will use the vector class to manage a dynamic array. After completing this assignment you will be able to ? use

In the assignment you will use the vector class to manage a dynamic array. After completing this assignment you will be able to ? use the vector class to implement programs; ? using iterators to more through a vector; ? use pointers to a vector; ? use member functions of the vector class. Assignment Description: Call your driver "vector_test_driver.cpp", your class declaration file vlist.h and your class implementation file "vlist.cpp". Define the following behavior for vlist 1. Implement a default constructor. Include the following message, "Default Constructor Invoked" every time the function is called.

2. Implement a copy constructor to perform a deep copy of a vlist object. Include the following message, "Copy Constructor Invoked" every time the function is called. The function should also print the contents of each vlist object on single separate lines.

3. Implement the destructor. Include the following message, "Destructor Invoked" every time the function is called.

4. Implement is_Empty() which returns true if empty; otherwise false.

5. Implement the member function called "Search" to search the vector for an item. The function will return an iterator to the location of the item in the vector it is there; otherwise, the function should print the message, Item Found or Item Not Found. Which message is printed depends on if the item was found or not found in the vector. Also, print the item (search key) you were looking for.

6. Implement a function called "insert" to add an item to the vector in order (alphabetical order). 7. Implement a function called "remove" to remove an item from the vector if it is there; otherwise prints a message stating it was not in vector; the function should use an iterator and the erase function to remove an item from the vector. 8. Implement the member function called Print, to print every item stored in the vector;

Your program should test the operation of the class on C++ strings. For this assignment, put the class declaration in the implementation file vlist.h" and the implementation file in vlist.cpp. Please consider the file vlist_driver.cpp and the following skeleton class to help you implement the class vlist:

class vlist { public: //vlist(); //default constructor //vlist(const vlist &); //copy constructor //~vlist(); //destructor //bool isEmpty(); //return true if empty; otherwise false //vector::iterator search(const string &); //returns the location of the string in the dynamic //array //void insert(const string & key); //add key to dynamic array //void remove(const string & key); //removes key from the vector if it is there; otherwise prints a //message stating it was not in vector; the function should use an iterator and the erase //function to //remove an item from the vector. //void print(); //Print every string in the vector //other functions may be implemented if necessary private: // vector DB; //vector //additonal state variables you may wish add }; Document your code well...

Good luck... Submission of Assignment: Submit the files vlist.h, vlist.cpp, and the driver vlist_driver.cpp ONLY in one zip file called program9_vector to Canvas before the due date and time. Remember, ask questions in class. You may need clarification on the assignment, so start early. Consider the following pieces of code to help you get started: /**********************************************************************************************

Sample skeleton for the file vlist.h. Remember to always add comments. Documentation is very important! **********************************************************************************************/ #include

using namespace std; #ifndef vlist_H

#define vlist_H class vlist

{

public:

vlist();

vlist(const vlist &);

~vlist();

bool Is_Empty();

vector::iterator Search(const string &);

void Insert(const string &);

void Remove(const string &);

void Print();

private:

vector DB;

}; #endif /********************************************************************** Sample skeleton for the file vlist.cpp Remember to always add comments. Documentation is very important!

***********************************************************************/ #include

#include

#include

#include "vlist.h" using namespace std; /////////////////////////////////////////////////////////////////////////////////////////////// ///////////////

//Function Name: vlist

//Precondition: Constructor has not been invoked.

//Postcondition: count=0, vector size is 9.

//Description: Constructs an instance of a vlist object.

/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////

vlist::vlist()

{

} /////////////////////////////////////////////////////////////////////////////////////////////// ///////////////

//Function Name: vlist

//Precondition: A vlist object is being passed by reference.

//Postcondition: A hard copy of a vlist object has been created.

//Description: Creates a hard copy of a vlist object.

/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////

vlist::vlist(const vlist & Org)

{

} /////////////////////////////////////////////////////////////////////////////////////////////// ///////////////

//Function Name: ~vlist

//Precondition: Destructor has not been invoked.

//Postcondition: array DB deleted.

//Description: Deallocates memory of a vlist object.

/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////

vlist::~vlist()

{

} bool vlist::is_Empty()

{

return true;

}

//vector::iterator vlist::Search(const string & key)

{

}

void vlist::Insert(const string & key)

{

}

void vlist::Remove(const string & key)

{

}

void vlist::Print()

{

} /******************************************************************************

S A M P L E T E S T D R I V E R Remember to always comment. Document is very important!

***********************************************************************/

#include

#include

#include "vlist.h"

using namespace std; int main()

{ //Testing default constructor

cout << "Test1:Testing the default constructor for string ";

vlist String_List; //Testing functionality for string list

cout << "Test2: Testing Insert ";

String_List.Insert("Hello");

String_List.Insert("Zebra");

String_List.Insert("Good_Bye");

String_List.Insert("Space");

String_List.Insert("No_One");

String_List.Print(); cout << "Test 3: Testing copy constructor for string ";

vlist Copied_String = String_List;

Copied_String.Print(); cout << "Test 4: Testing Remove for string ";

cout << "Testing Search and IsEmpty also ";

String_List.Remove("Zebra");

String_List.Remove("Good_Bye");

String_List.Remove("Hello");

String_List.Remove("No_One");

String_List.Remove("Space");

String_List.Remove("Hello"); cout<<"When leave main destructor will be called"<

}

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!