By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,193 Members | 826 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,193 IT Pros & Developers. It's quick & easy.

vector problem

P: 1
The Program

This assignment will use separate compilation. You MUST use the following guidelines for the design of your program:
You are given the header file TelephoneList.h which contain the function prototypes given below. Implements the function definitions in the implementation file TelephoneList.cpp.
void displayList(const vector<string>& nameList, const vector<int>& teleNumList) : This function displays the name and the corresponding number of all the persons in stored in nameList. The nameList contains the name list and teleNumList contains the corresponding telephone numbers. The pre-conditions are that both nameList and teleNumList have the same size and nth element of nameList corresponds to the nth element of teleNumList.

int search(const string& name, const vector<string>& nameList, const vector<int>& teleNumList) : This function returns the telephone number of the person name. If it fails to find the person in the nameList and the corresponding number in the teleNumList, it returns -1.

void append(const string& name, int teleNum, vector<string>& nameList, vector<int>& teleNumList) : This function appends the person name and the corresponding telephone number teleNum to the nameList and the teleNumList respectively.

bool update(const string& name, int teleNum, const vector<string>& nameList, vector<int>& teleNumList) : This function updates the telephone number of the person name to teleNum. The nameList and the teleNumList are the name list and the corresponding telephone number list. If it fails to find the person, it returns false otherwise it returns true.

bool erase(const string& name, vector<string>& nameList, vector<int>& teleNumList) : This function erases the person and the corresponding telephone number of the person name. The nameList and the teleNumList are the name list and the corresponding telephone number list. If it fails to find the person, it returns false otherwise it returns true.

..................................

#include <vector>
#include <string>
using namespace std;

void displayList(const vector<string>& nameList, const vector<int>& teleNumList);
int search(const string& name, const vector<string>& nameList, const vector<int>& teleNumList);
void append(const string& name, int teleNum, vector<string>& nameList, vector<int>& teleNumList);
bool update(const string& name, int teleNum, const vector<string>& nameList, vector<int>& teleNumList);
bool erase(const string& name, vector<string>& nameList, vector<int>& teleNumList);
Sep 18 '07 #1
Share this Question
Share on Google+
1 Reply


gpraghuram
Expert 100+
P: 1,275
The Program

This assignment will use separate compilation. You MUST use the following guidelines for the design of your program:
You are given the header file TelephoneList.h which contain the function prototypes given below. Implements the function definitions in the implementation file TelephoneList.cpp.
void displayList(const vector<string>& nameList, const vector<int>& teleNumList) : This function displays the name and the corresponding number of all the persons in stored in nameList. The nameList contains the name list and teleNumList contains the corresponding telephone numbers. The pre-conditions are that both nameList and teleNumList have the same size and nth element of nameList corresponds to the nth element of teleNumList.

int search(const string& name, const vector<string>& nameList, const vector<int>& teleNumList) : This function returns the telephone number of the person name. If it fails to find the person in the nameList and the corresponding number in the teleNumList, it returns -1.

void append(const string& name, int teleNum, vector<string>& nameList, vector<int>& teleNumList) : This function appends the person name and the corresponding telephone number teleNum to the nameList and the teleNumList respectively.

bool update(const string& name, int teleNum, const vector<string>& nameList, vector<int>& teleNumList) : This function updates the telephone number of the person name to teleNum. The nameList and the teleNumList are the name list and the corresponding telephone number list. If it fails to find the person, it returns false otherwise it returns true.

bool erase(const string& name, vector<string>& nameList, vector<int>& teleNumList) : This function erases the person and the corresponding telephone number of the person name. The nameList and the teleNumList are the name list and the corresponding telephone number list. If it fails to find the person, it returns false otherwise it returns true.

..................................

#include <vector>
#include <string>
using namespace std;

void displayList(const vector<string>& nameList, const vector<int>& teleNumList);
int search(const string& name, const vector<string>& nameList, const vector<int>& teleNumList);
void append(const string& name, int teleNum, vector<string>& nameList, vector<int>& teleNumList);
bool update(const string& name, int teleNum, const vector<string>& nameList, vector<int>& teleNumList);
bool erase(const string& name, vector<string>& nameList, vector<int>& teleNumList);

Hi,
Have u started working on it.
Please try it first anc ome back here withe the problems you face.
Raghuram
Sep 18 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.