Question: Using C++ Vector class . #include using namespace std; #include #include /*function prototypes*/ void showMenu(); void add(vectorchar> &ch); void remove(vectorchar> &ch); void show(vectorchar> &ch); int

Using C++ Vector class

. Using C++ Vector class . #include using namespace std; #include #include

#include

using namespace std;

#include

#include

/*function prototypes*/

void showMenu();

void add(vectorchar> &ch);

void remove(vectorchar> &ch);

void show(vectorchar> &ch);

int main(){

vectorchar> char_vec;

int input;

while (true) {

showMenu();

cin >> input;

switch (input){

case 1: add(char_vec);

break;

case 2: remove(char_vec);

break;

case 3: show(char_vec);

break;

case 4: return 0;

break;

default: cout

}

cout

}

return 0;

}

void showMenu() {

cout

cout

cout

cout

cout

}

/*complete the following functions: */

void add(vectorchar> &ch) {

/*prompt the user to enter a character

and add the character to the vector.*/

}

void remove(vectorchar> &ch) {

/*prompt the user to enter a character

to remove. then remove that character

from the vector.*/

/*HINT: you need to use the iterator

vector::iterator i to iterate through

your vector using a for loop. if the item

in your vector at that index is equal to the

key, then erase the item and print a message

stating that the item has been removed.*/

}

void show(vectorchar> &ch) {

/*print the contents of the vector.

remember to check if the vector is

empty first.*/

/*HINT: you need to use the iterator

vector::iterator i to loop

through your vector and print its

contents*/

}

Design the following menu-driven application using C++ Vector class. Implement the following five functions 1. Add(vector &ch) Prompts the user to provide a character and add that character into the vector 2. Remove(vector &ch) Prompts the user to provide a character. If the character is found in the vector, it removes that character. Otherwise, it generates a message 3. Show(vector &num) Show the existing members of the vector (order does not matter) . It will generate a message if it is empty Sample output: 1. Add a character 2. Remove a character. 3. Show the characters . Quit. Please enter a choice: 1 Please enter the character: a 1. Add a character 2. Remove a character. 3. Show the characters . Quit. Please enter a choice: 2 Please enter the character: c The character was not found 1. Add a character. 2. Remove a character. 3. Show the characters. 4. Quit Please enter a choice: 3 1. Add a character 2. Remove a character 3. Show the characters 4. Quit. Please enter a choice: 1 Please enter the character: b 1. Add a character. 2. Remove a character 3. Show the characters. 4. Quit. Please enter a choice: 2 Please enter the character: a The character has been removed

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!