Devam Ediyor

Project C++

input/output, operator overloading and dynamic memory management:

class record

{

private:

string fname, lname;

int IDnum;

public:

...

}

First, implement the default constructor (which initializes fname and lname to empty strings and IDnum to -1) and the constructor

record(string f,string l,int n)

(which initializes fname to f, etc.).

Next, overload the stream insertion and stream extraction operators . the format for a record is:

( fname lname IDnum )

where there can be arbitrary amounts of white space betwen each field and between the fields and the parentheses (recall that white space is a space, tab, newline, etc.). When reading in a record, you must check to see if the input is properly formatted. If it is not, then you should store -1 in IDnum. The IDnum field is what will be used to specify if a record is invalid. Since the user cannot directly access this field, you must define a member function called valid() that returns boolean type true if it is a valid record and false otherwise.

Finally, define these functions:

int readdb(record *& r, istream &s)

void printdb(record *r,int c,ostream &s)

Function readdb reads records one at a time from istream s using the overloaded stream extraction operator until the end of the input and writes them into an array pointed to by r (the array is to be allocated by readdb). Only valid records are to be read into the array! So e.g. if the following input is given on s:

( Stephen Scott 12345 )

( Leen-Kiat Soh )

( Richard Sincovec 6789 )

Ashok Samal 9914 )

then the first and third records will be stored in the array, but not the second or fourth. Since you don't know a priori how many valid records will be read in, start by pointing r to an array of size 2. After reading 2 records, double its size to 4. If you fill that, then double the size again, and so on. I.e., the size of the final array will be at most twice the number of records. Note that since r is a reference to a pointer to type record, you can point r to new arrays as needed. You should take advantage of this when resizing, which can be done by allocating a new array of twice the size and deleting the old one, or via the C command realloc.

The integer returned by readdb is the number of valid records read, not counting the number of invalid records. It is also not necessarily the final size of the array.

Function printdb takes as input a pointer r to an array of records, an integer c of how many records there are in the array (e.g. the value returned by readdb), and an ostream s to write the records to. Use the overloaded stream insertion operator to write all c records to s.

Beceriler: C Programlama

Daha fazlasını görün: project end time, old second, int size, int i, first advantage, field stream store, e value, directly, printdb, project management format, define project management, void, true, the c, strings, scott, resizing, pointing, memory c, leen, int, deleting, counting, c r, c access

İşveren Hakkında:
( 3 değerlendirme ) Linclon, United States

Proje NO: #42963

Seçilen:

pls

I have 12 years experience as a c++ programmer. This is no problem.

1 gün içinde 40$ USD
(1 Değerlendirme)
1.2

17 freelancer bu iş için ortalamada 39$ teklif veriyor

Aurochs

See PMB, please.

1 gün içinde 30$ USD
(40 Değerlendirme)
4.8
ccpplinux

Hi, Please see PMB for more details. Best Regards ... ccpplinux

in 2 gün içinde30$ USD
(6 Değerlendirme)
3.6
pectopatop2005

Please check PMB

in 2 gün içinde80$ USD
(1 Değerlendirme)
2.8
AhmadJalil

Please see PMB

1 gün içinde 30$ USD
(5 Değerlendirme)
2.2
regis

Hi! I've alredy done a few projects similar to this one (for students :-) ). I'm sure you will be pleased.

1 gün içinde 30$ USD
(0 Değerlendirme)
0.0
rolnik

I'm a computer scientist from Poland. I've been working as software engineer for the biggest polish software company. The request will be realised quick and professional.

1 gün içinde 30$ USD
(0 Değerlendirme)
0.0
jyo

I can do it.

in 2 gün içinde30$ USD
(0 Değerlendirme)
0.0
ARaheem

Hi Dear Rehan I am an experienced Developer, Just a new comer to getafreelancer. Not doing this project for the money instead want to have some ranking and some projects with my name. I can do the quality work fo Daha fazlası

1 gün içinde 30$ USD
(0 Değerlendirme)
0.0
jayanta77

Sipmle and easy way of doing the thing is splittng up and analyse in many ways and proceed to towards a better approach. I have an experience on c/C++ so i hope i have crack this to get a better view. Hope i will Daha fazlası

in 2 gün içinde30$ USD
(0 Değerlendirme)
0.0
prasadrkelamane

I can do this in 1 day. I have worked on similar things. I have worked on compilers.

1 gün içinde 30$ USD
(0 Değerlendirme)
0.0
dhariti

ready to start

in 3 gün içinde50$ USD
(0 Değerlendirme)
0.0
wojtekpeisert

I can do this for 30$. Below there is a header file as specified. There will be a need to add some access methods. If you decided to use an STL collection (here I suggest vector), there would be no need to manipu Daha fazlası

1 gün içinde 99$ USD
(0 Değerlendirme)
0.0
remur

easy task, you'll get it in less than one day

1 gün içinde 30$ USD
(0 Değerlendirme)
2.0
saurabhohri

The project is almost done with us Ready delievery

in 0 gün içinde30$ USD
(0 Değerlendirme)
0.0
sujayg

Can be done in 2 days.

in 2 gün içinde40$ USD
(0 Değerlendirme)
0.0
PujaSidana

Can be done in 2 days.

in 2 gün içinde30$ USD
(0 Değerlendirme)
0.0