473,782 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

vector problem

1 New Member
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.c pp.
void displayList(con st 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(con st 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 2300
gpraghuram
1,275 Recognized Expert Top Contributor
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.c pp.
void displayList(con st 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(con st 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
10629
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 namespace std; : : vector<string>* getTyphoon()
13
2154
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================================ class Buyer{ void start(void); friend void Buyer_run(Buyer *buyer);
11
2907
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 circumstances in which the STL will move a vector, or invalidate iterators to elements in the vector, if you don't insert or remove elements? My actual problem seems to be as follows: I have class X, which contains an STL vector. The constructor...
13
2358
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 Banana objects. In another method (getSecondBanana()) I want to access the contents of bananas, using e.g.
18
2577
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
2144
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 the vector of vectors according to the median value of one the dimensions. I tried to use the stl partition method like this: // S is a vector of vectors containing the points vector < vector <int> >::iterator iter;
11
1923
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 destruction of the assigned memory seems to call the class destructor more than once. I don't know the reason or whether I used the vector class correctly. Attached is my program. Thanks for your help. Regards,
9
3760
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" contains built-in types (e.g. int), then "clear()" doesn't remove anything at all. Why does "clear()" have this behaviour? Also, when I copy one vector "v1" from another vector "v2", with "v1" longer than "v2" (e.g. "v1" has 2 elements and "v2" has...
6
4002
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; class super{ protected:
4
1926
by: shuisheng | last post by:
Dear All, I have a question. Assume #include <vector> using namespace std; class A { private:
0
9643
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10313
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.