Em Andamento

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.

Habilidades: Programação C

Ver mais: the value of project management, t$c, project end time, old second, int size c, int i, first advantage, field and stream store, e value, directly, c for int, printdb, r in operator, project management format, define project management, write c++, VOID, true, the c, strings, scott, Resizing, project done most, project c++, pointing

Acerca do Empregador:
( 3 comentários ) Linclon, United States

ID do Projeto: #42963

Premiar a:

pls

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

$40 USD em 1 dia
(1 Comentário)
1.2

17 freelancers estão ofertando em média $39 para este trabalho

Aurochs

See PMB, please.

$30 USD em 1 dia
(40 Comentários)
4.8
ccpplinux

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

$30 USD in 2 dias
(6 Comentários)
3.6
pectopatop2005

Please check PMB

$80 USD in 2 dias
(1 Comentário)
2.8
AhmadJalil

Please see PMB

$30 USD em 1 dia
(5 Comentários)
2.2
regis

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

$30 USD em 1 dia
(0 Comentários)
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.

$30 USD em 1 dia
(0 Comentários)
0.0
jyo

I can do it.

$30 USD in 2 dias
(0 Comentários)
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 Mais

$30 USD em 1 dia
(0 Comentários)
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 Mais

$30 USD in 2 dias
(0 Comentários)
0.0
prasadrkelamane

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

$30 USD em 1 dia
(0 Comentários)
0.0
dhariti

ready to start

$50 USD in 3 dias
(0 Comentários)
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 Mais

$99 USD em 1 dia
(0 Comentários)
0.0
remur

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

$30 USD em 1 dia
(0 Comentários)
2.0
saurabhohri

The project is almost done with us Ready delievery

$30 USD in 0 dias
(0 Comentários)
0.0
sujayg

Can be done in 2 days.

$40 USD in 2 dias
(0 Comentários)
0.0
PujaSidana

Can be done in 2 days.

$30 USD in 2 dias
(0 Comentários)
0.0