473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

vector problem

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
1 2243
gpraghuram
1,275 Expert 1GB
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

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

Similar topics

7
by: Forecast | last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully. : // proj2.cc: returns a dynamic vector and prints out at main~~ : // : #include <iostream> : #include <vector> : : using...
13
by: Joseph | last post by:
I was doing my assignment,but encountered a problem at last step!!!!!! for easy reading, i ommited lots of other things //=====================code begin================================...
11
by: Richard Thompson | last post by:
I've got a memory overwrite problem, and it looks as if a vector has been moved, even though I haven't inserted or deleted any elements in it. Is this possible? In other words, are there any...
13
by: Steve | last post by:
I have defined the following private object: std::vector<Banana> bananas; in my header file. I have also added a method called FillVector(), which sets the size of the vector and fills it with...
18
by: imutate | last post by:
I have an integer variable and I am testing it as follows #define NULL_VAL -1 ... if (x.id != NULL_VAL) { std::cout << x.id << std::endl; ... }
0
by: acosgaya | last post by:
hi, I am working in this problem, where I have a set of N d-dimensional points, e.g. (4,5,6,8) (2,0,4,6), are 4-d points, which I have stored in a vector of vectors. I am trying to partition...
11
by: Brian | last post by:
Dear Programmers, I have a class with a pointer to an array. In the destructor, I just freed this pointer. A problem happens if I define a reference to a vector of this kind of class. The...
9
by: Jess | last post by:
Hello, I tried to clear a vector "v" using "v.clear()". If "v" contains those objects that are non-built-in (e.g. string), then "clear()" can indeed remove all contents. However, if "v"...
6
by: Jia | last post by:
Hi all, I have a class foo which has a static vector of pointers of type base class, and a static function to set this vector. #include <iostream> #include <vector> using namespace std;...
4
by: shuisheng | last post by:
Dear All, I have a question. Assume #include <vector> using namespace std; class A { private:
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.